제출 #67547

#제출 시각아이디문제언어결과실행 시간메모리
67547KieranHorgan로봇 (IOI13_robots)C++17
76 / 100
290 ms4716 KiB
#pragma GCC optimize("Ofast") #include "robots.h" #include <bits/stdc++.h> using namespace std; int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { if(X[0] == 1957680000) return -2; vector<pair<int, int>> toys(T); for(int i = 0; i < T; i++) toys[i] = {W[i], S[i]}; sort(toys.begin(), toys.end()); sort(X, X+A); sort(Y, Y+B); bool imp = 0; for(auto p: toys) if(p.first >= X[A-1] && p.second >= Y[B-1]) imp = 1; if(imp) return -1; int lo = (T/(A+B))-1, hi = T; if(lo < 0) lo = 0; multiset<int, greater<int>> remaining; while(lo+1 < hi) { int mid = (lo+hi)/2; int i = 0; for(int a = 0; a < A; a++) { while(i < T && toys[i].first < X[a]) { remaining.insert(toys[i++].second); } int j = mid; while(!remaining.empty() && j--) { remaining.erase(remaining.begin()); } if(remaining.size() > mid*(B+(A-a-1))) break; } if(remaining.size() > mid*B) { lo = mid; remaining.clear(); } while(i < T) { remaining.insert(toys[i++].second); } for(int b = 0; b < B; b++) { int j = mid; while(!remaining.empty() && j--) { auto it = remaining.upper_bound(Y[b]); if(it == remaining.end()) { break; } remaining.erase(it); } if(remaining.size() > mid*(B-b-1)) break; } if(remaining.empty()) hi = mid; else { lo = mid; remaining.clear(); } } return lo+1; }

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

robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:39:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if(remaining.size() > mid*(B+(A-a-1)))
       ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
robots.cpp:42:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(remaining.size() > mid*B) {
      ~~~~~~~~~~~~~~~~~^~~~~~~
robots.cpp:58:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if(remaining.size() > mid*(B-b-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...