제출 #718593

#제출 시각아이디문제언어결과실행 시간메모리
718593firewater로봇 (IOI13_robots)C++14
0 / 100
1 ms340 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.push(s[now++].sn); 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-1; while(l<r) { int mid=l+r>>1; if(check(mid,A,B,T))r=mid; else l=mid+1; } return l; }

컴파일 시 표준 에러 (stderr) 메시지

robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:46:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   46 |   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...