# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
134569 | 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[]){
priority_queue<P,vector<P>,greater<P> >Q;
sort(K,K+M);
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.empty())return 0;
if (Q.size()<K[i])return 0;
for (int j=0;j<K[i];j++)
P x=Q.top();
Q.pop();
if (x.first<=K[i]&&K[i]<=x.second)continue;
else return 0;
}
P x=Q.top();Q.pop();
while(x.first<=K[i]){
if (K[i]<x.second)Q.push(make_pair(K[i]+1,x.second));
x=Q.top();Q.pop();
}
}
return 1;
}