Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define ll long long
- #define ld long double
- #define pi pair<ll, ll>
- #define F first
- #define S second
- #define pb push_back
- #define PI acos(-1.0)
- using namespace std;
- ll n, m, a, Total;
- map<ll, ll> Age, Candie;
- set<ll> st;
- bool Can;
- int main()
- {
- ios::sync_with_stdio(0);
- cin.tie(0); cout.tie(0);
- // freopen("robots.in", "r", stdin);
- ll T; cin >> T;
- while(T--){
- Age.clear();
- Candie.clear();
- st.clear();
- Can = true;
- cin >> n >> m;
- for (int i=0; i<n; i++){
- cin >> a;
- Age[a]++;
- }
- for (int i=0; i<m; i++){
- cin >> a;
- st.insert(a);
- Candie[a]++;
- }
- for (auto i : Age){
- if (st.size() == 0){
- Can = false;
- break;
- }
- Total = 0;
- for (auto j : st){
- Total++;
- if (Candie[j] >= i.S)
- break;
- }
- while(st.size() && Total--) st.erase(st.begin());
- }
- cout << (Can ? "YES" : "NO") << '\n';
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement