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, int A[], 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,int k[]){
int ptr = -1;
vector<int> K;
for(int i = 0; i < m; i ++) K.pb(k[i]);
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_, a_[N], b_[N];
int inQ;
int inM, inK[N];
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) cin >> a_[i] >> b_[i];
init(n_, a_, b_);
while (inQ--) {
cin >> inM;
for (int i = 0; i < inM; ++i) cin >> inK[i];
cout << can(inM, inK) << "\n";
}
}
#endif // lpv
Compilation message (stderr)
teams.cpp: In function 'int can(int, int*)':
teams.cpp:38:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
38 | while(ptr + 1 < vr.size() && vr[ptr + 1].fi <= j) pq.push(vr[ptr + 1].se), ptr++;
| ~~~~~~~~^~~~~~~~~~~
teams.cpp:35:10: warning: unused variable 'ff' [-Wunused-variable]
35 | bool ff = true;
| ^~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |