Submission #120457

#TimeUsernameProblemLanguageResultExecution timeMemory
120457TuGSGeReLRobots (IOI13_robots)C++14
100 / 100
2003 ms24956 KiB
#include "robots.h" #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace std; using namespace __gnu_pbds; #define ll long long #define mp make_pair #define pub push_back #define pob pop_back() #define ss second #define ff first #define mt make_tuple #define pof pop_front() #define fbo find_by_order #define ook order_of_key #define lb lower_bound #define ub upper_bound typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set; using pll = pair <ll, ll>; using pii = pair <int, int>; int a, b, x[50001], y[50001], t; vector <pii> p; bool can(int k) { int j = 0; priority_queue<int> pq; for (int i = 0; i < a; i++) { while (j < t && p[j].ff < x[i]) pq.push(p[j++].ss); int kk = k; while (!pq.empty() && kk > 0) { kk--; pq.pop(); } } while ( j < t ) pq.push(p[j++].ss); for (int i = b - 1; i >= 0; i--) { int kk = k; while ( kk > 0 && !pq.empty() && y[i] > pq.top()) { pq.pop(); kk--; } } if ( pq.empty() ) return 1; return 0; } int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { a = A; b = B; t = 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++) p.pub(mp(W[i], S[i])); sort(p.begin(), p.end()); sort(x, x + a); sort(y, y + b); int l = 1, r = 1e6; while (l + 1 < r) { int mid = (l + r) / 2; if ( can(mid) ) r = mid; else l = mid; } if ( can(l) ) return l; else if ( can(r) ) return r; else return -1; }
#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...