제출 #545537

#제출 시각아이디문제언어결과실행 시간메모리
545537timreizin로봇 (IOI13_robots)C++17
0 / 100
1 ms304 KiB
#include "robots.h" #include <vector> #include <algorithm> #include <map> using namespace std; int putaway(int a, int b, int t, int X[], int Y[], int W[], int S[]) { vector<int> x(a), y(b); vector<pair<int, int>> ws(t); for (int i = 0; i < a; ++i) x[i] = X[i]; for (int i = 0; i < b; ++i) y[i] = Y[i]; for (int i = 0; i < t; ++i) ws[i] = {W[i], S[i]}; sort(ws.begin(), ws.end(), [](auto a, auto b){ return a.second > b.second; }); sort(y.begin(), y.end(), greater<>()); auto check = [&ws, &x, &y](int m) -> bool { multimap<int, int> help; for (int i : x) help.insert({i, m}); vector<int> left(y.size(), m); int ind = 0; for (auto [w, s] : ws) { auto it = help.upper_bound(w); if (it == help.end()) { if (ind == left.size()) return false; if (y[ind] <= s) return false; --left[ind]; if (left[ind] == 0) ++ind; continue; } --it->second; if (it->second == 0) help.erase(it); } return true; }; if (!check(t)) return -1; int l = 0, r = t; while (l < r) { int m = (l + r) >> 1; if (check(m)) r = m; else l = m + 1; } return l; }

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

robots.cpp: In lambda function:
robots.cpp:28:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |                 if (ind == left.size()) return false;
      |                     ~~~~^~~~~~~~~~~~~~
#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...