kl1nov

Untitled

Dec 11th, 2019
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef vector<int> vi;
  4. typedef vector<vi> vvi;
  5.  
  6. void sort (vi& a)
  7. {
  8. for (int j = 1; j < a.size(); j++)
  9. {
  10. int t = j - 1, p = a[j];
  11. while(t >= 0 && a[t] > p )
  12. {
  13. a[t + 1] = a[t];
  14. t--;
  15. }
  16. a[t + 1] = p;
  17. }
  18. }
  19.  
  20. int main()
  21. {
  22. int n, m, k;
  23. cin >> n >> m;
  24. vi a(n * m, 0);
  25. for (int i = 0; i < n * m ; i++)
  26. cin >> a[i];
  27. cin >> k;
  28. vi b(k, 0);
  29. for (int i = 0; i < k; i++)
  30. cin >> b[i];
  31. sort(a);
  32. sort(b);
  33. int npl = 0, cnt = 0;
  34. for (int i = 0; i < k; i++)
  35. {
  36. while (b[i] > a[npl]
  37. && npl < n * m)
  38. {
  39. npl++;
  40. }
  41. if (npl == n * m) break;
  42. else
  43. {
  44. cnt++;
  45. npl++;
  46. }
  47.  
  48. }
  49.  
  50. cout << cnt;
  51. }
Add Comment
Please, Sign In to add comment