Submission #73034

#TimeUsernameProblemLanguageResultExecution timeMemory
73034MKopchevTeams (IOI15_teams)C++14
34 / 100
4030 ms20588 KiB
#include<bits/stdc++.h> #include "teams.h" using namespace std; int n; vector< pair<int,int> > inp; void init(int N,int A[],int B[]) { n=N; for(int i=0;i<N;i++) inp.push_back({A[i],B[i]}); sort(inp.begin(),inp.end()); } priority_queue<int> q,idle; int can(int m,int k[]) { q=idle; sort(k,k+m); int pos=0; for(int i=0;i<m;i++) { int p=k[i]; while(pos<n&& inp[pos].first<=p) {q.push(-inp[pos].second);pos++;} while(q.size()&&-q.top()<p)q.pop(); //cout<<p<<" -> "<<q.size()<<endl; if(q.size()<p)return 0; for(int j=1;j<=p;j++) q.pop(); } return 1; } /* int main() { init(4,[1,2,2,2],[2,3,3,4]); cout<<call(2,[1,3])<<endl; cout<<call(2,[1,1])<<endl; } */

Compilation message (stderr)

teams.cpp: In function 'int can(int, int*)':
teams.cpp:27:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if(q.size()<p)return 0;
            ~~~~~~~~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...