Submission #927868

#TimeUsernameProblemLanguageResultExecution timeMemory
927868panRobots (IOI13_robots)C++17
100 / 100
1707 ms52532 KiB
#include <bits/stdc++.h> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> //#include "bits_stdc++.h" #define f first #define s second #define pb push_back #define mp make_pair #define lb lower_bound #define ub upper_bound #define input(x) scanf("%lld", &x); #define input2(x, y) scanf("%lld%lld", &x, &y); #define input3(x, y, z) scanf("%lld%lld%lld", &x, &y, &z); #define input4(x, y, z, a) scanf("%lld%lld%lld%lld", &x, &y, &z, &a); #define print(x, y) printf("%lld%c", x, y); #define show(x) cerr << #x << " is " << x << endl; #define show2(x,y) cerr << #x << " is " << x << " " << #y << " is " << y << endl; #define show3(x,y,z) cerr << #x << " is " << x << " " << #y << " is " << y << " " << #z << " is " << z << endl; #define discretize(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end()); using namespace std; //using namespace __gnu_pbds; #define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> #define ordered_multiset tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> typedef long long ll; typedef long double ld; typedef pair<ld, ll> pd; typedef pair<string, ll> psl; typedef pair<ll, ll> pi; typedef pair<ll, pi> pii; #ifndef __ROBOTS_H__ #define __ROBOTS_H__ #ifdef __cplusplus extern "C" { #endif int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { vector<pi> weight(T), size(T); for (ll i=0; i<T; ++i) { weight[i] = mp(W[i], i); size[i] = mp(S[i], i); } sort(weight.begin(), weight.end()); sort(size.begin(), size.end()); sort(X, X+A); sort(Y, Y+B); ll lo = 1, hi = T+1; while (lo!=hi) { ll counting = 0; ll mid = (lo+hi)/2; vector<ll> finish(T, false); ll l= -1; priority_queue<pi> pq; for (ll i=0; i<A; ++i) { while (l+1<T && weight[l+1].f<X[i]) { l++; ll ind = weight[l].s; pq.push(mp(S[ind], ind)); } ll counter = mid; while (counter-- && pq.size()) { ll ind = pq.top().s; pq.pop(); finish[ind] = true; counting++; } } l = -1; ll can = 0; for (ll i=0; i<B; ++i) { while (l+1<T && size[l+1].f<Y[i]) { l++; if (!finish[size[l].s]) can++; } counting+= min(can, mid); can -= min(can, mid); } if (counting==T) hi = mid; else lo = mid+1; } if (lo==T+1) return -1; return lo; } #ifdef __cplusplus } #endif #endif /* __ROBOTS_H__ */
#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...