Submission #134747

#TimeUsernameProblemLanguageResultExecution timeMemory
134747BoxworldTeams (IOI15_teams)C++14
13 / 100
4011 ms19276 KiB
#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++)Q.push(make_pair(a[i].l,a[i].r)); while(Q.top().first<K[0]){ P x=Q.top(); Q.pop(); if (K[0]<=x.second){ Q.push(make_pair(K[0],x.second)); } if (Q.empty())break; } 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; 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())break; } } return 1; }

Compilation message (stderr)

teams.cpp: In function 'int can(int, int*)':
teams.cpp:26:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (Q.size()<K[i])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...