Submission #718625

#TimeUsernameProblemLanguageResultExecution timeMemory
718625firewaterRobots (IOI13_robots)C++14
100 / 100
1659 ms23292 KiB
#include "robots.h" #include<queue> #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #define ll long long #define N 1001000 #define mp make_pair #define fs first #define sn second using namespace std; int l,r,now,a[N],b[N],sa[N],sb[N]; pair<int,int>s[N]; priority_queue<int>d; bool check(int t,int A, int B, int T) { for(int i=1;i<=A;++i) sa[i]=t; for(int i=1;i<=B;++i) sb[i]=t; while(!d.empty())d.pop(); now=1; for(int i=1;i<=A;++i){ while(now<=T&&s[now].fs<a[i])d.push(s[now++].sn); while((sa[i]--)&&!d.empty())d.pop(); } while(now<=T)d.push(s[now++].sn); for(int i=B;i>0;--i) while((sb[i]--)&&!d.empty()&&d.top()<b[i])d.pop(); return d.empty(); } int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { for(int i=1;i<=A;++i) a[i]=X[i-1]; for(int i=1;i<=B;++i) b[i]=Y[i-1]; for(int i=1;i<=T;++i) s[i]=mp(W[i-1],S[i-1]); sort(a+1,a+1+A); sort(b+1,b+1+B); sort(s+1,s+1+T); if(!check(T,A,B,T))return -1; l=1; r=T; while(l<r) { int mid=l+r>>1; if(check(mid,A,B,T))r=mid; else l=mid+1; } return l; }

Compilation message (stderr)

robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:48:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   48 |   int mid=l+r>>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...
#Verdict Execution timeMemoryGrader output
Fetching results...