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;
#define ll long long
#define pb push_back
typedef pair<ll,ll> pii;
const ll MAXN = 5e5+5;
const ll INF = 1e15+7;
vector<pii> stud;
int n;
void init(int N, int A[], int B[]) {
ll i;
pii x;
for(i=0;i<N;i++){
x.first=A[i];
x.second=B[i];
stud.pb(x);
}
sort(stud.begin(),stud.end());
n=N;
}
int can(int M, int K[]) {
sort(K,K+M);
ll i,cur=0,sum=0,p;
pii x;
for(i=0;i<M;i++){
sum+=K[i];
}
if(sum>n)return 0;
priority_queue<pii>children;
for(i=0;i<M;i++){//ver os primeiros que podem ir
while(cur<n && stud[cur].first<=K[i]){
children.push({-stud[cur].second,stud[cur].first});
cur++;
}
//e preciso k[i] crianças validas
p=K[i];
while(p--){
if(children.empty())return 0;
x=children.top();
children.pop();
if((-x.first)<K[i])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... |