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 <vector>
#include <set>
std::vector<int> right[500005];
int NN;
void init(int N, int A[], int B[]) {
NN=N;
for(int i=0;i<N;i++){
right[A[i]].push_back(B[i]);
}
}
int can(int M, int K[]) {
std::vector<int> freq(NN+1);
int sum=0;
for(int i=0;i<M;i++){
freq[K[i]]+=K[i];
sum+=K[i];
if(sum>NN) return 0;
}
std::multiset<int> active;
for(int i=1;i<=NN;i++){
for(int v:right[i]){
active.insert(v);
}
while(active.size()&&*active.begin()<i) active.erase(active.begin());
while(freq[i]--){
if(active.empty()) return 0;
active.erase(active.begin());
}
}
return 1;
}
# | 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... |