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 <bits/stdc++.h>
using namespace std;
vector<pair<int,int>> ranges;
int n;
void init(int N, int A[], int B[]) {
n=N;
ranges.resize(n);
for (int i=0; i<n; i++){
ranges[i].first=A[i];
ranges[i].second=B[i];
}
sort(ranges.begin(),ranges.end());
}
int can(int m, int k[]) {
sort(k,k+m);
int tot = 0;
for (int i = 0; i<m; i++){
tot+=k[i];
}
if (tot!=n){
return 0;
}
int ptr = 0;
priority_queue<int,vector<int>,greater<int>> pq;
for (int i = 0; i<m; i++){
for (int j = 0; j<k[i]; j++){
while (ptr<n&&ranges[ptr].first<=k[i]){
pq.push(ranges[ptr].second);
ptr++;
}
if (pq.size()==0||pq.top()<k[i]){
return 0;
}
pq.pop();
}
}
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... |