이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "robots.h"
#include <bits/stdc++.h>
using namespace std;
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]);
bool check(int a,int t,int w[],int x[],int X) {
int i,j = 0,cnt=0;
for(i=0;i<t;){
if(j>=a)return 0;
if(w[i]<x[j]){
cnt++;
i++;
}else{
j++;
cnt = 0;
}
if(cnt==X) {
j++;
cnt=0;
}
}
if(i!=t)return 0;
return 1;
}
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
if(A+B==2&&T==2) {
sort(X,X+A);
sort(Y,Y+B);
if(!A){
if(S[0]<Y[0]&&S[1]<Y[1])return 1;
if(S[0]<Y[1]&&S[1]<Y[1])return 2;
return -1;
}
else if(!B){
if(W[0]<X[0]&&W[1]<X[1])return 1;
if(W[0]<X[1]&&W[1]<X[1])return 2;
return -1;
}else{
if((W[0]<X[0]&&S[1]<Y[0])||(S[0]<Y[0]&&W[1]<X[0]))return 1;
if((W[0]<X[0]&&W[1]<X[0])||(S[0]<Y[0]&&S[1]<Y[0]))return 2;
return -1;
}
}
sort(W,W+T);
sort(X,X+A);
if(W[T-1]>X[A-1])return -1;
int l=1,r=T,ans=T;
while(l<=r){
int mid=(l+r)/2;
if (check(A,T,W,X,mid)) {
ans=mid;
r=mid-1;
}else{
l=mid+1;
}
}
return ans;
}
# | 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... |