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