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[500100];
priority_queue<P,vector<P>,greater<P> >Q;
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];
}
int can(int M, int K[]){
while(!Q.empty())Q.pop();
sort(K,K+M);
for (int i=0;i<n;i++){
if (a[i].l<K[0]){
if(K[0]<=a[i].r)Q.push(make_pair(K[0],a[i].r));
}else 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;
}
if (i==M-1)return 1;
if (Q.empty())return 0;
while(Q.top().first<K[i+1]){
P x=Q.top();
Q.pop();
if (K[i+1]<=x.second)Q.push(make_pair(K[i+1],x.second));
if (Q.empty())return 0;
}
}
return 1;
}
Compilation message (stderr)
teams.cpp: In function 'int can(int, int*)':
teams.cpp:22:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (Q.size()<K[i])return 0;
~~~~~~~~^~~~~
# | 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... |