제출 #993404

#제출 시각아이디문제언어결과실행 시간메모리
993404Muaath_5로봇 (IOI13_robots)C++17
28 / 100
276 ms37992 KiB
#pragma GCC optimize("Ofast,O3,unroll-loops") #pragma GCC target("avx2,avx,sse3,sse4") #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[]) { sort(X, X+A); sort(Y, Y+B); vector<pair<int, int>> v; for (int i = 0; i < T; i++) v.push_back({W[i], S[i]}); sort(v.begin(), v.end()); for (int i = 0; i < T; i++) { W[i] = v[i].first, S[i] = v[i].second; if (A && B) if (W[i] >= X[A-1] && S[i] >= Y[B-1]) return -1; if (A && !B) if (W[i] >= X[A-1]) return -1; if (!A && B) if (S[i] >= Y[B-1]) return -1; } if (T == 2 && A+B == 2) { if (A==2) { if (*max_element(X, X+A) <= *max_element(W, W+T)) return -1; if (X[0] > W[0] && X[1] > W[1]) return 1; return 2; } if (B==2) { if (*max_element(Y, Y+B) <= *max_element(S, S+T)) return -1; if (Y[0] > S[0] && Y[1] > S[1]) return 1; return 2; } if ((X[0] > W[0] && Y[0] > S[1]) || (X[0] > W[1] && Y[0] > S[0])) return 1; if ((X[0] > W[0] && X[0] > W[1]) || (Y[0] > S[0] && Y[0] > S[1])) return 2; return -1; } if (B == 0) { multiset<int> s; for (int i = 0; i < T; i++) s.insert(W[i]); int sol = 0; while (s.size()) { for (int i = A-1; s.size() && i >= 0; i--) { auto it = s.lower_bound(X[i]); if (it == s.begin()) break; it--; s.erase(it); } sol++; } return sol; } int l = 1, r = T; while (l < r) { const int mid = (l+r)/2; int idx = T-1; multiset<int> s; for (int i = A-1; idx >= 0 && i >= 0; i--) { int cnt = 0; while (idx >= 0 && X[i] <= v[idx].first) { s.insert(v[idx].second); idx--; } idx -= mid; } bool ok = true; for (int i = B; i >= 0; i--) { for (int j = 0; j < mid; j++) { if (*s.rbegin() >= Y[i]) { ok = false; break; } } if (!ok) break; } if (ok) l = mid; else r = mid-1; } return l; }

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

robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:69:17: warning: unused variable 'cnt' [-Wunused-variable]
   69 |             int cnt = 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...