제출 #585171

#제출 시각아이디문제언어결과실행 시간메모리
585171Drew_로봇 (IOI13_robots)C++17
100 / 100
351 ms9160 KiB
#include "robots.h" #include <bits/stdc++.h> using namespace std; #define pb push_back #define f1 first #define s2 second using ii = pair<int, int>; const int MAX = 5e4 + 69; int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { if (A > B) swap(A, B), swap(X, Y), swap(W, S); sort(X, X+A); sort(Y, Y+B); for (int i = 0; i < T; ++i) { if ((A == 0 || X[A-1] <= W[i]) && (B == 0 || Y[B-1] <= S[i])) return -1; } vector<ii> vec; for (int i = 0; i < T; ++i) { int p = (int)(upper_bound(X, X+A, W[i]) - X); int q = (int)(upper_bound(Y, Y+B, S[i]) - Y); vec.pb({p, q}); } sort(vec.rbegin(), vec.rend()); int ar[MAX]; const auto check = [&](int val) -> bool { for (int i = 0; i <= B; ++i) ar[i] = 0; for (int i = 0, ctr = 0; i < T; ++i) { if (ctr < 1ll * (A - vec[i].f1) * val) ctr++; else ar[0]++, ar[vec[i].s2 + 1]--; } for (int i = 1; i <= B; ++i) ar[i] += ar[i-1]; for (int i = 0; i <= B; ++i) if (ar[i] > 1ll * (B-i) * val) return false; return true; }; int l = 1, r = T; while (l < r) { int mid = (l + r) >> 1; if (check(mid)) r = mid; else l = mid + 1; } return l; }
#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...