kl1nov

Untitled

Dec 11th, 2019
96
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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, 0);
  25. vi b(m, 0);
  26.  
  27. for (int i = 0; i < n * m ; i++)
  28. cin >> a[i];
  29. cin >> k;
  30. for (int i = 0; i < k; i++)
  31. cin >> b[k];
  32. sort(a);
  33. sort(b);
  34. int npl = 0, cnt = 0;
  35. for (int i = 0; i < n; i++)
  36. {
  37. while (a[i] > b[npl]
  38. && npl < n * m)
  39. {
  40. npl++;
  41. if (npl == n * m) break;
  42. else
  43. {
  44. cnt++;
  45. npl++;
  46. }
  47. }
  48. }
  49.  
  50. cout << cnt;
  51.  
  52.  
  53.  
  54. }
RAW Paste Data