This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "teams.h"
#include <cmath>
#include <algorithm>
#include <iostream>
#include <queue>
using namespace std;
const int maxn=5e5+5;
priority_queue < int, vector < int >, greater < int > > q;
vector < int > sw[maxn];
int n;
void init(int x, int a[], int b[]){
n=x;
for(int i=0; i<n; i++){
sw[a[i]].push_back(b[i]+1);
}
}
int can(int m, int k[]){
sort(k, k+m);
int pos=0;
for(int i=0; i<=n; i++){
for(int j=0; j<(int)sw[i].size(); j++){
q.push(sw[i][j]);
}
while(!q.empty() && q.top()==i){
q.pop();
}
// cout << "sz " << q.size() << endl;
while(pos<m && k[pos]==i){
if((int)q.size()<i){
while(!q.empty()){
q.pop();
}
return 0;
}
for(int j=0; j<i; j++){
q.pop();
}
pos++;
}
}
while(!q.empty()){
q.pop();
}
return 1;
}
/*
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
int a[n], b[n];
for(int i=0; i<n; i++){
cin >> a[i] >> b[i];
}
init(n, a, b);
int q;
cin >> q;
for(int i=0; i<q; i++){
int m;
cin >> m;
int c[m];
for(int j=0; j<m; j++){
cin >> c[j];
}
cout << can(m, c) << '\n';
}
return 0;
}
*/
# | 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... |