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 }
View Code

相关文章:

  • 2022-01-27
  • 2022-01-27
  • 2022-01-13
  • 2021-11-11
  • 2021-10-07
  • 2021-12-28
  • 2021-07-02
  • 2021-11-18
猜你喜欢
  • 2022-02-01
  • 2021-12-17
  • 2021-08-28
  • 2021-11-21
  • 2021-10-13
相关资源
相似解决方案