Submission #1070319

#TimeUsernameProblemLanguageResultExecution timeMemory
1070319allin27xRobots (IOI13_robots)C++17
90 / 100
651 ms30544 KiB
#include <bits/stdc++.h> #include "robots.h" using namespace std; const int MAXT = 1e6+2; array<int,2> T[MAXT]; int ex[MAXT]; multiset<pair<int,int>> bt; bool check(int a, int b, int t, int X[], int Y[], int cp) { for (int i=0; i<t; i++) ex[i] = 1; for (int i=0; i<b; i++) bt.insert({Y[i], cp}); for (int i=0; i<t; i++) { auto it = bt.lower_bound({T[i][1], 1}); if (it == bt.end()) continue; pair<int,int> q = *it; bt.erase(it); q.second--; if (q.second) bt.insert(q); ex[i] = 0; } vector<int> W; for (int i=t-1; i>=0; i--) if (ex[i]) W.push_back(T[i][0]); if (W.empty()) return 1; if (W[W.size()-1] > X[a-1]) return 0; int mc = a-1; int toy = W.size()-1; int cnt = 0; vector exc(a, 0); while (mc){ while (toy >=0 && X[mc-1] < W[toy]) toy--, cnt++; exc[mc] = cnt; cnt = 0; mc--; } exc[mc] = toy+1; int ans = 1; for (int i=a-2; i>=0; i--) exc[i] = exc[i+1]+exc[i]; for (int i=0; i<a; i++) ans = max(ans, (exc[i]+a-1-i)/(a-i)); return (ans<=cp); } int putaway(int a, int b, int t, int X[], int Y[], int W[], int S[]){ for (int i=0; i<t; i++) W[i]++; for (int i=0; i<t; i++) S[i]++; sort(X, X+a); sort(Y, Y+b); for (int i = 0; i < t; i++) T[i][0] = W[i], T[i][1] = S[i]; sort(T, T+t, greater<array<int,2>>()); int l = 1, r = t+1; while (l<r) { bt.clear(); int m = (l+r)/2; if (check(a,b,t,X,Y,m)) r = m; else l = m+1; } if (l==t+1) return -1; else 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...