# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
962782 | simona1230 | Robots (IOI13_robots) | C++17 | 87 ms | 10596 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 <bits/stdc++.h>
#include "robots.h"
using namespace std;
int a,b,t,x[50000],y[50000],w[50000],s[50000];
bool check(int k)
{
int idx=t-1;
for(int i=a-1;i>=0;i--)
{
int cnt=0;
while(idx>=0&&cnt<k&&w[idx]<x[i])
{
idx--;
cnt++;
}
}
if(idx==-1)return 1;
return 0;
}
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<a;i++)
x[i]=X[i];
for(int i=0;i<b;i++)
y[i]=Y[i];
for(int i=0;i<t;i++)
w[i]=W[i],s[i]=S[i];
sort(x,x+a);
sort(y,y+b);
if(a+b==2&&t==2)
{
if(a==2)
{
sort(w,w+t);
if(x[0]>w[0]&&x[1]>w[1])return 1;
if(x[1]>w[1])return 2;
return -1;
}
if(b==2)
{
sort(s,s+t);
if(y[0]>s[0]&&y[1]>s[1])return 1;
if(y[1]>s[1])return 2;
return -1;
}
if(x[0]>w[0]&&y[0]>s[1]||x[0]>w[1]&&y[0]>s[0])return 1;
if(x[0]<=w[0]&&y[0]<=s[0]||x[0]<=w[1]&&y[0]<=s[1])return -1;
return 2;
}
if(b==0)
{
sort(w,w+t);
int l=1,r=t;
int ans=-1;
while(l<=r)
{
int m=(l+r)/2;
if(check(m))
{
ans=m;
r=m-1;
}
else l=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... |