제출 #367777

#제출 시각아이디문제언어결과실행 시간메모리
367777idk321로봇 (IOI13_robots)C++11
100 / 100
1909 ms24824 KiB
#include "robots.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; vector<array<int, 2>> toys; int a; int b; int* x; int* y; bool poss(int t) { int cur = 0; priority_queue<int> sett; for (int i = 0; i < a; i++) { while (cur < toys.size() && toys[cur][0] < x[i]) { sett.push(toys[cur][1]); cur++; } for (int j = 0; j < t; j++) { if (sett.empty()) break; sett.pop(); } } while (cur < toys.size()) { sett.push(toys[cur][1]); cur++; } int t2 = 0; for (int i = b - 1; i >= 0; i--) { for (int j = 0; j < t; j++) { if (sett.empty()) return true; if (y[i] <= sett.top()) return false; sett.pop(); } } if (sett.empty()) return true; return false; } int bs() { int a = 1; int b = toys.size(); int res = -1; while (a <= b) { int mid = (a + b) / 2; if (poss(mid)) { res = mid; b = mid - 1; } else { a = mid + 1; } } return res; } int putaway(int A, int B, int t, int X[], int Y[], int w[], int s[]) { a = A; b = B; toys.resize(t); x = X; y = Y; for (int i = 0; i < t; i++) { toys[i][0] = w[i]; toys[i][1] = s[i]; } sort(toys.begin(), toys.end()); sort(x, x + a); sort(y, y + b); return bs(); }

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

robots.cpp: In function 'bool poss(int)':
robots.cpp:21:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::array<int, 2> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |         while (cur < toys.size() && toys[cur][0] < x[i])
      |                ~~~~^~~~~~~~~~~~~
robots.cpp:34:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::array<int, 2> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |     while (cur < toys.size())
      |            ~~~~^~~~~~~~~~~~~
robots.cpp:39:9: warning: unused variable 't2' [-Wunused-variable]
   39 |     int t2 = 0;
      |         ^~
#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...