# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
386272 | jjang36524 | Robots (IOI13_robots) | C++14 | 7 ms | 8940 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "robots.h"
#include <algorithm>
#include <queue>
#include <vector>
#include <string.h>
using namespace std;
vector<int>Wl[100000];
vector<int>Sl[100000];
int us[1000100];
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[])
{
sort(X,X+A);
sort(Y,Y+B);
int i;
for(i=0;i<T;i++)
{
int x=upper_bound(X,X+A,W[i])-X;
int y=upper_bound(Y,Y+B,S[i])-Y;
if(x==A&&y==B)
{
return -1;
}
Wl[x].push_back(i);
Sl[y].push_back(i);
}
int s=1;
int e=T;
while(s!=e)
{
int m=(s+e)/2;
priority_queue<pair<int,int>>tc;
memset(us,0,sizeof(us));
int i;
for(i=0;i<A;i++)
{
int j;
for(j=0;j<Wl[i].size();j++)
{
tc.push({S[Wl[i][j]],Wl[i][j]});
}
for(j=0;j<m;j++)
{
if(tc.empty())
break;
auto a=tc.top();
tc.pop();
us[a.second]=1;
}
}
int c=0;
for(i=0;i<B;i++)
{
int j;
for(j=0;j<Sl[i].size();j++)
{
if(!us[Sl[i][j]])
{
c++;
}
}
c=max(0,c-m);
}
if(c)
s=m+1;
else
e=m;
}
return s;
}
Compilation message (stderr)
# | 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... |