daily pastebin goal
45%
SHARE
TWEET

Untitled

a guest Mar 24th, 2019 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2. #define ll long long
  3. #define ld long double
  4. #define pi pair<ll, ll>
  5. #define F first
  6. #define S second
  7. #define pb push_back
  8. #define PI acos(-1.0)
  9. using namespace std;
  10. ll n, m, a, Total;
  11. map<ll, ll> Age, Candie;
  12. set<ll> st;
  13. bool Can;
  14. int main()
  15. {
  16.     ios::sync_with_stdio(0);
  17.     cin.tie(0); cout.tie(0);
  18.     // freopen("robots.in", "r", stdin);
  19.  
  20.     ll T;   cin >> T;
  21.     while(T--){
  22.         Age.clear();
  23.         Candie.clear();
  24.         st.clear();
  25.         Can = true;
  26.  
  27.         cin >> n >> m;
  28.         for (int i=0; i<n; i++){
  29.             cin >> a;
  30.             Age[a]++;
  31.         }
  32.         for (int i=0; i<m; i++){
  33.             cin >> a;
  34.             st.insert(a);
  35.             Candie[a]++;
  36.         }
  37.  
  38.         for (auto i : Age){
  39.             if (st.size() == 0){
  40.                 Can = false;
  41.                 break;
  42.             }
  43.             Total = 0;
  44.             for (auto j : st){
  45.                 Total++;
  46.                 if (Candie[j] >= i.S)
  47.                     break;
  48.             }
  49.             while(st.size() && Total--) st.erase(st.begin());
  50.         }
  51.         cout << (Can ? "YES" : "NO") << '\n';
  52.     }
  53.     return 0;
  54. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top