Submission #718598

#TimeUsernameProblemLanguageResultExecution timeMemory
718598firewaterRobots (IOI13_robots)C++14
90 / 100
3086 ms11096 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]; pair<int,int>s[N]; priority_queue<int>d; bool check(int t,int A, int B, int 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); for(int j=1;j<=t&&!d.empty();++j) d.pop(); } while(now<=T&&d.size()<=B*t)d.push(s[now++].sn); if(d.size()>B*t)return false; for(int i=B;i>0&&!d.empty();--i) for(int j=1;j<=t&&!d.empty();++j) if(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=(T+(A+B)-1)/(A+B); 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 'bool check(int, int, int, int)':
robots.cpp:25:24: warning: comparison of integer expressions of different signedness: 'std::priority_queue<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   25 |  while(now<=T&&d.size()<=B*t)d.push(s[now++].sn);
      |                ~~~~~~~~^~~~~
robots.cpp:26:13: warning: comparison of integer expressions of different signedness: 'std::priority_queue<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   26 |  if(d.size()>B*t)return false;
      |     ~~~~~~~~^~~~
robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:47:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   47 |   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...