Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef vector<int> vi;
- typedef vector<vi> vvi;
- void sort (vi& a)
- {
- for (int j = 1; j < a.size(); j++)
- {
- int t = j - 1, p = a[j];
- while(t >= 0 && a[t] > p )
- {
- a[t + 1] = a[t];
- t--;
- }
- a[t + 1] = p;
- }
- }
- int main()
- {
- int n, m, k;
- cin >> n >> m;
- vi a(n * m, 0);
- for (int i = 0; i < n * m ; i++)
- cin >> a[i];
- cin >> k;
- vi b(k, 0);
- for (int i = 0; i < k; i++)
- cin >> b[i];
- sort(a);
- sort(b);
- int npl = 0, cnt = 0;
- for (int i = 0; i < k; i++)
- {
- while (b[i] > a[npl]
- && npl < n * m)
- {
- npl++;
- }
- if (npl == n * m) break;
- else
- {
- cnt++;
- npl++;
- }
- }
- cout << cnt;
- }
Add Comment
Please, Sign In to add comment