제출 #159629

#제출 시각아이디문제언어결과실행 시간메모리
159629rama_pang로봇 (IOI13_robots)C++14
100 / 100
2036 ms26680 KiB
#include "robots.h" #include <bits/stdc++.h> using namespace std; int A, B, T; vector<int> robotW, robotS, W, S, items; bool is_possible(int t) { priority_queue<int> size; // sorted by size int cur = 0; for (int i = 0; i < A; i++) { while (cur < T && W[items[cur]] < robotW[i]) size.push(S[items[cur++]]); int sz = size.size(); while (size.size() > max(0, sz - t)) size.pop(); } while (cur < T) size.push(S[items[cur++]]); for (int i = B - 1; i >= 0; i--) { int sz = size.size(); while (size.size() > max(0, sz - t) && size.top() < robotS[i]) size.pop(); } return size.empty(); } int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { for (int i = 0; i < T; i++) ::W.push_back(W[i]); for (int i = 0; i < T; i++) ::S.push_back(S[i]); for (int i = 0; i < A; i++) robotW.push_back(X[i]); for (int i = 0; i < B; i++) robotS.push_back(Y[i]); items.resize(T); iota(items.begin(), items.end(), 0); sort(items.begin(), items.end(), [&](int a, int b) { return W[a] < W[b]; }); if (robotW.size()) sort(robotW.begin(), robotW.end()); if (robotS.size()) sort(robotS.begin(), robotS.end()); ::A = A, ::B = B, ::T = T; int res = T + 1; int le = 1, ri = T; while (le <= ri) { int mid = (le + ri) / 2; if (is_possible(mid)) { res = mid; ri = mid - 1; } else { le = mid + 1; } } res = (res > T)? -1 : res; return res; }

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

robots.cpp: In function 'bool is_possible(int)':
robots.cpp:15:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         while (size.size() > max(0, sz - t)) size.pop();
                ~~~~~~~~~~~~^~~~~~~~~~~~~~~~
robots.cpp:22:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         while (size.size() > max(0, sz - t) && size.top() < robotS[i]) size.pop();
                ~~~~~~~~~~~~^~~~~~~~~~~~~~~~
#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...