| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1348682 | simona_2010 | 로봇 (IOI13_robots) | C++20 | 0 ms | 0 KiB |
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include "robots.h"
using namespace std;
int a, b, t, x[50005], y[50005], w[1000005], s[1000005];
bool check(int x)
{
int pos = 0, cnt = 0;
for(int i = 0; i < t; i++)
{
if(cnt == x)pos++;
if(pos >= a)return false;
while(w[i] >= x[pos] && pos < a)
{
pos++;
cnt = 0;
}
if(pos == a)return false;
cnt++;
}
return true;
}
int bin_search()
{
int l = 1, r = t;
while(l <= r)
{
int mid = (l+r)/2;
if(check(mid))r = mid-1;
else l = mid+1;
}
if(l > t)return -1;
return l;
}
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[])
{
if(T == 2 && A+B == 2)
{
if(A == 1 && B == 1)
{
if(W[0] < X[0] && S[1] < Y[0])return 1;
if(W[1] < X[0] && S[0] < Y[0])return 1;
if(W[0] < X[0] && W[1] < X[0])return 2;
if(S[0] < Y[0] && S[1] < Y[0])return 2;
return -1;
}
if(A == 2)
{
if(W[0] < X[0] && W[1] < X[1])return 1;
if(W[1] < X[0] && W[0] < X[1])return 1;
if(W[0] < X[0] && W[1] < X[0])return 2;
if(W[0] < X[1] && W[1] < X[1])return 2;
return -1;
}
if(B == 2)
{
if(S[0] < Y[0] && S[1] < Y[1])return 1;
if(S[1] < Y[0] && S[0] < Y[1])return 1;
if(S[0] < Y[0] && S[1] < Y[0])return 2;
if(S[0] < Y[1] && S[1] < Y[1])return 2;
}
}
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(w, w+t);
sort(s, s+t);
return bin_search();
}
