# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
309998 | amunduzbaev | 로봇 (IOI13_robots) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "robots.h"
#include "grader.cpp"
#include <bits/stdc++.h>
using namespace std;
const int N=1e6+5;
const int N1=5e4+5;
int t,a,b,a1[N1],b1[N1],w[N],s[N];
int used[N1];
bool check(int m){
memset(used,0,sizeof(used));
for(int i=0;i<t;i++){
int l=0,r=a-1;
while(l<r){
int mid=(l+r)/2;
if(a1[mid]>=w[i])
r=mid;
else
l=mid+1;
}
while(used[l]==m&&l<a)
l++;
if(l==a&&used[l]==m)
return 0;
used[l]++;
}
return 1;
}
int putaway(int A, int B, int T, int A1[], int B1[], int W[], int S[]) {
t=T,a=A,b=B;
for(int i=0;i<t;i++){
w[i]=W[i];
s[i]=S[i];
}
for(int i=0;i<a;i++) a1[i]=A1[i];
for(int i=0;i<b;i++) b1[i]=B1[i];
sort(a1,a1+a);
sort(b1,b1+b);
for(int i=0;i<t;i++){
if(a&&b){
if(w[i]>=a1[a-1]&&s[i]>=b1[b-1]) return -1;
}else if(a){
if(w[i]>=a1[a-1]) return -1;
}else{
if(s[i]>=b1[b-1]) return -1;
}
}
if(t==2){
if(a>0&&b>0){
return (a1[0]>w[0]&&b1[0]>s[1]||a1[0]>w[1]&&b1[0]>s[0]) ? 1 : 2 ;
}
if(a>0){
return (a1[0]>w[0]&&a1[1]>w[1]||a1[1]>w[0]&&a1[0]>w[1]) ? 1 : 2 ;
}
if(b>0){
return (b1[0]>s[0]&&b1[1]>s[1]||b1[1]>s[0]&&b1[0]>s[1]) ? 1 : 2 ;
}
}
int l=1,r=t;
while(l<r){
int m=(l+r)/2;
if(check(m))
r=m-1;
else
l=m;
}
return l;
}
/*
*/