Submission #478241

#TimeUsernameProblemLanguageResultExecution timeMemory
478241joshjmsRobots (IOI13_robots)C++14
100 / 100
2325 ms11748 KiB
#include "robots.h" #include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define pb push_back #define fi first #define se second #define konaqua ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define otsuaqua exit(0); #define debug(x) cout << #x << " => " << x << "\n" #define all(x) x.begin(), x.end() #define sp " " #pragma GCC optimize("Os") #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") const ll INFF = 1e18 + 5; const ll INF = 1e10 + 5; const int MX = 1e6 + 5; const int MXL = 105; const int mod = 1e9 + 7; const double ERROR = 1e-8; const ld pi = 3.14159265358979323846; const int set_inf = 0x3f3f3f3f; int a, b, t; int l, r, md, ans = -1; pair <int,int> toys[1000005]; int x[50005], y[50005]; set <pair<int,int>> st; int sr[50005], wr[50005], it; bool check(){ for(int i = 0; i < a; i++) wr[i] = 0; for(int i = 0; i < b; i++){ sr[i] = 0; st.insert({y[i], i}); } it = a - 1; for(int i = t - 1; i >= 0; i--){ if(st.empty()){ if(it < 0) return 0; if(toys[i].fi >= x[it]) return 0; wr[it]++; if(wr[it] >= md) it--; continue; } auto idx = st.upper_bound({toys[i].se, 1e9 + 7}); if(idx == st.end()){ if(it < 0) return 0; if(toys[i].fi >= x[it]) return 0; wr[it]++; if(wr[it] >= md) it--; continue; } pair <int,int> p = *idx; sr[p.se]++; if(sr[p.se] >= md) st.erase(idx); } return 1; } 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 < t; i++) toys[i] = make_pair(W[i], S[i]); sort(toys, toys + t); for(int i = 0; i < a; i++) x[i] = X[i]; sort(x, x + a); for(int i = 0; i < b; i++) y[i] = Y[i]; sort(y, y + b); l = 1, r = t; while(l <= r){ md = (l + r) / 2; if(check()){ r = md - 1, ans = md; } else l = md + 1; } return ans; }
#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...