이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#include"robots.h"
using namespace std;
const int MAXN = 1e6 + 10;
int a, b, t, x[MAXN], y[MAXN], s[MAXN], w[MAXN];
bool check(int xt)
{
int index = 0;
for (int i = 0; i < a; ++ i)
{
if(index == t)return true;
int put = 0;
while(index < t && put < xt && w[index] < x[i])
{
index ++;
put ++;
}
}
return (index == t);
}
int putaway(int A,int B,int T, int X[],int Y[],int W[],int S[])
{
/// 14p
if(A + B == 2 && T == 2)
{
int fit00 = 0, fit01 = 0, fit10 = 0, fit11 = 0;
if(A == 2)
{
if(W[0] < X[0])fit00 ++;
if(W[1] < X[0])fit01 ++;
if(W[0] < X[1])fit10 ++;
if(W[1] < X[1])fit11 ++;
}
else if(B == 2)
{
if(S[0] < Y[0])fit00 ++;
if(S[1] < Y[0])fit01 ++;
if(S[0] < Y[1])fit10 ++;
if(S[1] < Y[1])fit11 ++;
}
else
{
if(W[0] < X[0])fit00 ++;
if(W[1] < X[0])fit01 ++;
if(S[0] < Y[0])fit10 ++;
if(S[1] < Y[0])fit11 ++;
}
if(!fit01 && !fit11)return -1;
if(!fit00 && !fit10)return -1;
if(fit01 && fit10)return 1;
if(fit00 && fit11)return 1;
return 2;
}
/// sort + make global
sort(X, X+A);
sort(W, W+T);
for (int i = 0; i < T; ++ i)
{
s[i] = S[i];
w[i] = W[i];
}
for (int i = 0; i < A; ++ i)
x[i] = X[i];
for (int i = 0; i < B; ++ i)
y[i] = Y[i];
a = A;
b = B;
t = T;
if(B == 0)
{
if(X[A-1] <= W[T-1])return -1;
int l = 1, r = t, mid = 0, ans = t;
while(l <= r)
{
mid = (l + r)/2;
if(check(mid))
{
ans = mid;
r = mid - 1;
}
else l = mid + 1;
}
return ans;
}
}
컴파일 시 표준 에러 (stderr) 메시지
robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:89:1: warning: control reaches end of non-void function [-Wreturn-type]
89 | }
| ^
# | 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... |