Submission #104469

#TimeUsernameProblemLanguageResultExecution timeMemory
104469eriksuenderhaufRobots (IOI13_robots)C++11
100 / 100
1825 ms24960 KiB
#pragma GCC optimize("O3") #include <bits/stdc++.h> #include "robots.h" //#include "grader.h" #define enl printf("\n") #define case(t) printf("Case #%d: ", (t)) #define ni(n) scanf("%d", &(n)) #define nl(n) scanf("%I64d", &(n)) #define nai(a, n) for (int i = 0; i < (n); i++) ni(a[i]) #define nal(a, n) for (int i = 0; i < (n); i++) nl(a[i]) #define pri(n) printf("%d\n", (n)) #define prl(n) printf("%I64d\n", (n)) #define pii pair<int, int> #define pll pair<long long, long long> #define vii vector<pii> #define vi vector<int> #define pb push_back #define mp make_pair #define fi first #define se second using namespace std; typedef long long int ll; const double pi = acos(-1); const int MOD = 1e9 + 9; const int INF = 1e9 + 7; const int MAXN = 1e6 + 5; const double eps = 1e-9; int x[MAXN], y[MAXN]; pii arr[MAXN]; int a, b, t; bool ok(int cnt) { priority_queue<int> act; int l = 0; for (int i = 0; i < a; i++) { while (l < t && x[i] > arr[l].fi) act.push(arr[l++].se); for (int j = 0; j < cnt; j++) { if (act.empty()) break; act.pop(); } } while (l < t) act.push(arr[l++].se); for (int i = b-1; i >= 0; i--) { for (int j = 0; j < cnt; j++) { if (act.empty()) return true; if (act.top() >= y[i]) return false; act.pop(); } } if (act.empty()) return true; return false; } //w<x;s<y int putaway(int A, int B, int T, int X[], int Y[], int w[], int s[]) { a = A, b = B, t = T; int mxX = 0, mxY = 0; for (int i = 0; i < a; i++) { x[i] = X[i]; mxX = max(mxX, X[i]); } sort(x, x + a); for (int i = 0; i < b; i++) { y[i] = Y[i]; mxY = max(mxY, Y[i]); } sort(y, y + b); for (int i = 0; i < t; i++) { arr[i] = {w[i], s[i]}; if (w[i] >= mxX && s[i] >= mxY) return -1; } sort(arr, arr + t); int lo = 1, hi = t, ret = t; while (lo <= hi) { int mi = (lo + hi) / 2; if (ok(mi)) hi = mi - 1, ret = mi; else lo = mi + 1; } return ret; }
#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...