제출 #198702

#제출 시각아이디문제언어결과실행 시간메모리
198702arnold518로봇 (IOI13_robots)C++14
100 / 100
2085 ms26944 KiB
#include "robots.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 5e4; const int MAXT = 1e6; struct Toy { int W, S; }; int A, B, T, X[MAXN+10], Y[MAXN+10]; Toy toy[MAXT+10]; bool decide(int x) { int i, j, k; priority_queue<int> PQ; for(i=1, j=1; i<=A; i++) { for(; j<=T && toy[j].W<X[i]; j++) PQ.push(toy[j].S); for(k=0; k<x && !PQ.empty(); k++) PQ.pop(); } for(; j<=T; j++) PQ.push(toy[j].S); vector<int> V; while(!PQ.empty()) V.push_back(PQ.top()), PQ.pop(); reverse(V.begin(), V.end()); int sz=0; for(i=1, j=0; i<=B; i++) { for(; j<V.size() && V[j]<Y[i]; j++) sz++; sz-=min(sz, x); } for(; j<V.size(); j++) sz++; if(sz==0) return true; return false; } int putaway(int _A, int _B, int _T, int *_X, int *_Y, int *_W, int *_S) { int i, j; A=_A; B=_B; T=_T; for(i=1; i<=T; i++) toy[i]={_W[i-1], _S[i-1]}; for(i=1; i<=A; i++) X[i]=_X[i-1]; for(i=1; i<=B; i++) Y[i]=_Y[i-1]; sort(toy+1, toy+T+1, [&](const Toy &p, const Toy &q) { return p.W<q.W; }); sort(X+1, X+A+1); sort(Y+1, Y+B+1); int lo=0, hi=1e6; while(lo+1<hi) { int mid=lo+hi>>1; if(decide(mid)) hi=mid; else lo=mid; } if(hi==1e6) hi=-1; return hi; }

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

robots.cpp: In function 'bool decide(int)':
robots.cpp:35:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(; j<V.size() && V[j]<Y[i]; j++) sz++;
               ~^~~~~~~~~
robots.cpp:38:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(; j<V.size(); j++) sz++;
           ~^~~~~~~~~
robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:59:19: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
         int mid=lo+hi>>1;
                 ~~^~~
robots.cpp:46:12: warning: unused variable 'j' [-Wunused-variable]
     int i, j;
            ^
#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...