Submission #419969

#TimeUsernameProblemLanguageResultExecution timeMemory
419969PbezzTeams (IOI15_teams)C++14
0 / 100
4075 ms28252 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...