Submission #134582

#TimeUsernameProblemLanguageResultExecution timeMemory
134582BoxworldTeams (IOI15_teams)C++14
13 / 100
4017 ms17324 KiB
#include "teams.h" #include <bits/stdc++.h> using namespace std; typedef pair<int,int> P; struct S{int l,r;}a[500100]; 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[]){ // printf("New_Day\n"); priority_queue<P,vector<P>,greater<P> >Q; 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)); // printf("NEW l:%d r:%d\n",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(); // printf("Work[%d] l:%d r:%d\n",K[i],x.first,x.second); 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)); // printf("NEW l:%d r:%d\n",K[i+1],x.second); } if (Q.empty())break; } } return 1; }

Compilation message (stderr)

teams.cpp: In function 'int can(int, int*)':
teams.cpp:27: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...