제출 #67567

#제출 시각아이디문제언어결과실행 시간메모리
67567thebes로봇 (IOI13_robots)C++14
100 / 100
2318 ms15596 KiB
#include "robots.h" #include <bits/stdc++.h> using namespace std; typedef pair<int,int> pii; const int MN = 1e6+6; pair<int,int> wts[MN]; priority_queue<int> q; int N, M, T, i; vector<int> a, b; bool check(int m){ while(q.size()) q.pop(); int i=0, j = 0; for(i=0,j=0;i<N;i++){ while(j<T&&wts[j].first<a[i]) q.push(wts[j++].second); for(int k=0;k<m&&q.size();k++) q.pop(); } for(;j<T;j++) q.push(wts[j].second); for(int k=b.size()-1;k>=0;k--){ for(int i=0;i<m&&q.size()&&q.top()<b[k];i++) q.pop(); } return q.empty(); } int putaway(int A,int B,int t,int *X,int *Y,int *W,int *S){ N = A, M = B, T = t; for(int i=0;i<T;i++) wts[i] = {W[i],S[i]}; for(int i=0;i<N;i++) a.push_back(X[i]); for(int i=0;i<M;i++) b.push_back(Y[i]); sort(a.begin(),a.end()); sort(b.begin(),b.end()); sort(wts,wts+T,[](pii i,pii j){return i.first<j.first;}); int lo = 1, hi = T+1; while(lo<hi){ int m = lo+hi>>1; if(check(m)) hi=m; else lo=m+1; } return(hi==T+1)?-1:hi; }

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

robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:37:13: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   int m = lo+hi>>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...