Submission #250240

#TimeUsernameProblemLanguageResultExecution timeMemory
250240MarcoMeijerRobots (IOI13_robots)C++14
100 / 100
2020 ms26764 KiB
#include "robots.h" #include <bits/stdc++.h> using namespace std; //macros typedef long long ll; typedef pair<int, int> ii; typedef pair<ll, ll> lll; typedef tuple<int, int, int> iii; typedef vector<int> vi; typedef vector<ii> vii; typedef vector<iii> viii; typedef vector<ll> vll; typedef vector<lll> vlll; #define REP(a,b,c) for(int a=int(b); a<int(c); a++) #define RE(a,c) REP(a,0,c) #define RE1(a,c) REP(a,1,c+1) #define REI(a,b,c) REP(a,b,c+1) #define REV(a,b,c) for(int a=int(c-1); a>=int(b); a--) #define INF 1e9 #define pb push_back #define fi first #define se second #define sz size() const int MX=1e6+1e5; int a, b, t; int x[MX], y[MX], w[MX], s[MX]; int SA[MX]; bool possible(int T) { int n=0; priority_queue<int> pq; RE(i,a) { while(n != t && w[SA[n]] < x[i]) { pq.push(s[SA[n++]]); } RE(j,T) { if(pq.empty()) break; pq.pop(); } } while(n != t) { pq.push(s[SA[n++]]); } RE(i,b) { RE(j,T) { if(pq.empty()) return 1; if(pq.top() >= y[i]) return 0; pq.pop(); } } return pq.empty(); } int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { a=A; b=B; t=T; RE(i,A) x[i]=X[i]; RE(i,B) y[i]=Y[i]; RE(i,T) w[i]=W[i], s[i]=S[i]; RE(i,t) SA[i]=i; sort(SA,SA+t, [](int i, int j) { return w[i]<w[j]; }); sort(x,x+a); sort(y,y+b,greater<int>()); int lb=0, ub=T; while(lb != ub) { int mid=(lb+ub)/2; if(possible(mid)) ub=mid; else lb=mid+1; } if(!possible(lb)) lb=-1; return lb; }
#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...