Ankit_132

D1

Oct 22nd, 2023 (edited)
372
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.78 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define _test   int _TEST; cin>>_TEST; while(_TEST--)
  6.  
  7. int main()
  8. {
  9.     _test
  10.     {
  11.         int n, m;
  12.         cin>>n>>m;
  13.  
  14.         vector<int> a(n), b(n);
  15.  
  16.         a[0] = 1;
  17.         for(int i=1; i<n; i++)
  18.             cin>>a[i];
  19.  
  20.         for(auto &e: b)     cin>>e;
  21.  
  22.         multiset<int> msta, mstb;
  23.         for(auto e: a)      msta.insert(e);
  24.         for(auto e: b)      mstb.insert(e);
  25.  
  26.         int cnt = 0;
  27.  
  28.         while(msta.size())
  29.         {
  30.             if(mstb.upper_bound(*msta.rbegin()) != mstb.end())
  31.             {
  32.                 cnt++;
  33.                 mstb.erase(mstb.upper_bound(*msta.rbegin()));
  34.             }
  35.  
  36.             msta.erase(--msta.end());
  37.         }
  38.  
  39.         cout<<n - cnt<<"\n";
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment