# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
718598 | firewater | Robots (IOI13_robots) | C++14 | 3086 ms | 11096 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<queue>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define ll long long
#define N 1001000
#define mp make_pair
#define fs first
#define sn second
using namespace std;
int l,r,now,a[N],b[N];
pair<int,int>s[N];
priority_queue<int>d;
bool check(int t,int A, int B, int T)
{
while(!d.empty())d.pop();
now=1;
for(int i=1;i<=A;++i){
while(now<=T&&s[now].fs<a[i])d.push(s[now++].sn);
for(int j=1;j<=t&&!d.empty();++j)
d.pop();
}
while(now<=T&&d.size()<=B*t)d.push(s[now++].sn);
if(d.size()>B*t)return false;
for(int i=B;i>0&&!d.empty();--i)
for(int j=1;j<=t&&!d.empty();++j)
if(d.top()<b[i])d.pop();
return d.empty();
}
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
for(int i=1;i<=A;++i)
a[i]=X[i-1];
for(int i=1;i<=B;++i)
b[i]=Y[i-1];
for(int i=1;i<=T;++i)
s[i]=mp(W[i-1],S[i-1]);
sort(a+1,a+1+A);
sort(b+1,b+1+B);
sort(s+1,s+1+T);
if(!check(T,A,B,T))return -1;
l=(T+(A+B)-1)/(A+B);
r=T;
while(l<r)
{
int mid=l+r>>1;
if(check(mid,A,B,T))r=mid;
else l=mid+1;
}
return l;
}
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... |