A. Game Shopping
签.
1 #include <bits/stdc++.h> 2 using namespace std; 3 4 #define N 1010 5 int n, m, c[N]; 6 queue <int> q; 7 8 int main() 9 { 10 while (scanf("%d%d", &n, &m) != EOF) 11 { 12 while (!q.empty()) q.pop(); 13 for (int i = 1; i <= n; ++i) scanf("%d", c + i); 14 for (int i = 1, x; i <= m; ++i) 15 { 16 scanf("%d", &x); 17 q.push(x); 18 } 19 int res = 0; 20 for (int i = 1; i <= n && !q.empty(); ++i) 21 { 22 if (q.front() >= c[i]) 23 { 24 q.pop(); 25 ++res; 26 } 27 } 28 printf("%d\n", res); 29 } 30 return 0; 31 }