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 <queue>
#include <algorithm>
using namespace std;
int n;
vector<pair<int,int>> arr;
void init(int N, int A[], int B[]) {
n=N;
for(int i=0;i<n;i++)arr.push_back({A[i],B[i]});
sort(arr.begin(),arr.end());
}
int can(int M, int K[]) {
int sum = 0;
vector<int>q;
for(int i=0;i<M;i++)sum += K[i];
for(int i=0;i<M;i++)q.push_back(K[i]);
if(sum > n)return 0;
int skip = n-sum;
int pos = 0;
int minT = n;
int cur = 0;
int cnt = 0;
sort(q.begin(),q.end());
while(true){
if(arr[pos].second < q[cnt] or arr[pos].first > q[cnt]){
if(skip>0)skip--;
else{return 0;}
}else{
minT = min(minT,arr[pos].second);
cur++;
if(q[cnt] == cur){
cnt++;
cur = 0;
minT=n;
}
if(cnt == M)return 1;
}
pos ++;
if(pos == n)return 0;
}
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... |