Submission #1008798

#TimeUsernameProblemLanguageResultExecution timeMemory
1008798c2zi6Robots (IOI13_robots)C++14
28 / 100
120 ms17444 KiB
#define _USE_MATH_DEFINES #include <bits/stdc++.h> #define ff first #define ss second #define pb push_back #define all(a) (a).begin(), (a).end() #define replr(i, a, b) for (int i = int(a); i <= int(b); ++i) #define reprl(i, a, b) for (int i = int(a); i >= int(b); --i) #define rep(i, n) for (int i = 0; i < int(n); ++i) #define mkp(a, b) make_pair(a, b) using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> PII; typedef vector<int> VI; typedef vector<PII> VPI; typedef vector<VI> VVI; typedef vector<VVI> VVVI; typedef vector<VPI> VVPI; typedef pair<ll, ll> PLL; typedef vector<ll> VL; typedef vector<PLL> VPL; typedef vector<VL> VVL; typedef vector<VVL> VVVL; typedef vector<VPL> VVPL; template<class T> T setmax(T& a, T b) {if (a < b) return a = b; return a;} template<class T> T setmin(T& a, T b) {if (a < b) return a; return a = b;} #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; template<class T> using indset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #include "robots.h" namespace TEST1 { int solve(int A, int B, int T, int X[], int Y[], int W[], int S[]) { if (A == 2) { VI x{X[0], X[1]}; VI w{W[0], W[1]}; sort(all(x)); sort(all(w)); if (w[0] < x[0] && w[1] < x[1]) return 1; if (w[1] < x[1]) return 2; return -1; } if (B == 2) { VI y{Y[0], Y[1]}; VI s{S[0], S[1]}; sort(all(y)); sort(all(s)); if (s[0] < y[0] && s[1] < y[1]) return 1; if (s[1] < y[1]) return 2; return -1; } int x = X[0]; int y = Y[0]; if (W[0] < x && S[1] < y) return 1; if (W[1] < x && S[0] < y) return 1; if (W[0] < x && W[1] < x) return 2; if (S[0] < y && S[1] < y) return 2; return -1; } }; namespace TEST2 { int solve(int A, int B, int T, int X[], int Y[], int W[], int S[]) { VI a(A); rep(i, A) a[i] = X[i]; VI b(T); rep(i, T) b[i] = W[i]; sort(all(b)); for (int& x : a) x = lower_bound(all(b), x)-b.begin()-1; sort(all(a)); reverse(all(a)); auto can = [&](int c) { ll cur = b.size()-1; for (ll j : a) { if (cur > j) return false; j = min(j, cur); cur = j-c; } return cur < 0; }; int l = 0; int r = 1e9; while (l + 1 < r) { int m = (l + r) / 2; if (can(m)) r = m; else l = m; } if (r == 1e9) return -1; return r; } }; int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { if (A + B == 2 && T == 2) return TEST1::solve(A, B, T, X, Y, W, S); if (B == 0) return TEST2::solve(A, B, T, X, Y, W, S); 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...