Submission #262800

#TimeUsernameProblemLanguageResultExecution timeMemory
262800uacoder123Robots (IOI13_robots)C++14
76 / 100
3074 ms40152 KiB
#include <bits/stdc++.h> #include "robots.h" using namespace std; #define F first #define S second #define FOR(i,a,b) for (auto i = (a); i <= (b); ++i) #define NFOR(i,a,b) for(auto i = (a); i >= (b); --i) #define all(x) (x).begin(), (x).end() #define sz(x) lli(x.size()) #define mp(i,a) make_pair(i,a) #define pb(a) push_back(a) #define bit(x,b) (x&(1LL<<b)) typedef long long int lli; typedef pair <lli,lli> ii; typedef pair <lli,ii> iii; typedef vector <lli> vi; lli t,a,b; vector<ii> v; vi v1,v2; lli check(lli m) { lli j=0; multiset<lli> s; for(lli i=0;i<a;++i) { while(j!=t&&v[j].F<v1[i]) { s.insert(v[j].S); j++; } lli co=0; while(co!=m&&s.size()) { s.erase(((--s.end()))); co++; } } while(j!=t) { s.insert(v[j].S); j++; } for(lli i=0;i<b;++i) { lli co=0; while(co!=m&&s.size()&&(*s.begin())<v2[i]) { s.erase((s.begin())); co++; } } if(s.size()) return 0; return 1; } int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { t=T; a=A; b=B; for(lli i=0;i<a;++i) v1.pb(X[i]); for(lli i=0;i<b;++i) v2.pb(Y[i]); for(lli i=0;i<t;++i) v.pb(mp(W[i],S[i])); sort(all(v)); sort(all(v1)); sort(all(v2)); lli l=1,r=t,ans=t+1; while(l<=r) { int m=(l+r)/2; if(check(m)) { r=m-1; ans=m; } else l=m+1; } return (ans<=t)?ans:-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...