# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
550829 | David_M | Robots (IOI13_robots) | C++14 | 3063 ms | 37600 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "robots.h"
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define pb push_back
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
int ans=-1;
vector<array<int, 3>> p(T);
for (int i=0; i<T; i++)p[i]={W[i]+1, S[i]+1, i};
sort(all(p));
sort(X, X+A);
sort(Y, Y+B);
int l=1, r=T+1;
while(l<=r){
int m=l+r>>1;
int M=0, k=0, o=0;
vector<bool> f(T,0);
vector<int> v;
set<array<int, 2>> s;
for (auto[x,y,i] : p){
if(A==0)break;
M=m;
if(x>X[k]){
while(s.size() && M--){
f[(*s.begin())[1]]=1;
s.erase(s.begin());
}
while(k<A && x>X[k])k++;
if(k==A)break;
}
s.insert({-y,i});
}
while(k<A){
M=m;
while(s.size() && M--){
f[(*s.begin())[1]]=1;
s.erase(s.begin());
}
k++;
}
for (int i=0; i<T; i++)
if(!f[i])v.pb(S[i]+1);
k=M=0;
for (auto y : v){
if(B==0){o=1;break;}
while(k<B && y>Y[k])k++,M=0;
if(k==B){o=1;break;}
M++;
if(M==m)k++,M=0;
if(k==B){o=1;break;}
}
if(o)l=m+1; else ans=m, r=m-1;
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |