# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
134566 | Boxworld | Teams (IOI15_teams) | C++14 | 0 ms | 0 KiB |
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;
typedef pair<int,int> P;
struct S{int l,r;}a[100100];
bool cmp(S x,S y){return x.l<y.l?1:(x.r<y.r?1:0);}
int n;
void init(int N, int A[], int B[]){
n=N;
for (int i=0;i<N;i++){
a[i].l=A[i];a[i].r=B[i];
}
// sort(a,a+N,cmp);
// for (int i=0;i<N;i++)printf("L:%d R:%d\n",a[i].l,a[i].r);
}
int can(int M, int K[]){
int head=0;
sort(K,K+M);
priority_queue<P,vector<P>,greater<P> >Q;
for (int i=0;i<n;i++)Q.push(make_pair(a[i].l,a[i].r));
for (int i=0;i<M;i++){
if (Q.size()<K[i])return 0;
for (int j=0;j<K[i];j++)
P p=Q.top();Q.pop();
if (p.first<=K[i]&&K[i]<=p.second)continue;
else return 0;
}
while(Q.top().first<=K[i]){
P p=Q.top();Q.pop();
if (K[i]<p.second)Q.push(make_pair(K[i]+1,p.second));
}
}
return 1;
}