# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
971850 | VinhLuu | Teams (IOI15_teams) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define all(lmao) lmao.begin(), lmao.end()
using namespace std;
typedef pair<int,int> pii;
typedef tuple<int,int,int> tp;
const int N = 1e6 + 5;
int block = 555;
const int mod = 1e9 + 7;
//const ll oo = 5e18;
int n;
vector<pii> vr;
void init(int _n, vector<int> A, vector<int> B){
n = _n;
for(int i = 0; i < n; i ++){
vr.pb({A[i], B[i]});
}
sort(all(vr), [&](pii x,pii y){return x.fi < y.fi;});
}
int can(int m,vector<int> K){
int ptr = -1;
sort(all(K));
bool ff = true;
priority_queue<int,vector<int>, greater<int>> pq;
for(auto j : K){
while(ptr + 1 < vr.size() && vr[ptr + 1].fi <= j) pq.push(vr[ptr + 1].se), ptr++;
int u = j;
while(u){
if(pq.empty()) return 0;
if(pq.top() >= j) u--;
pq.pop();
}
}
return 1;
}
//#define lpv
#ifdef lpv
int n_;
vector<int> a_, b_;
int inQ;
int inM;
vector<int> inK;
signed main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define task "v"
if(fopen(task ".inp","r")){
freopen(task ".inp","r",stdin);
freopen(task ".out","w",stdout);
}
cin >> n_ >> inQ;
for (int i = 0; i < n_; ++i){
int x, y; cin >> x >> y;
a_.pb(x);
b_.pb(y);
}
init(n_, a_, b_);
while (inQ--) {
cin >> inM;
for (int i = 0; i < inM; ++i){
int x; cin >> x; inK.pb(x);
}
cout << can(inM, inK) << "\n";
}
}
#endif // lpv