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 <fstream>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
using namespace std;
const int nmax=1000*1000+5;
pair<int,int> v[nmax];
int a[nmax],b[nmax];
priority_queue<int> pq;
int A,B,i,n,j;
bool check(int val)
{
while(!pq.empty()) pq.pop();
int p=1;
for(i=1;i<=A;i++)
{
while(p<=n&&v[p].first<a[i])
{
pq.push(v[p].second);
p++;
}
for(j=1;j<=val&&(!pq.empty());j++)
pq.pop();
}
while(p<=n)
{
pq.push(v[p].second);
p++;
}
for(i=B;i>=1;i--)
{
for(j=1;j<=val&&(!pq.empty())&&pq.top()<b[i];j++)
pq.pop();
}
return (pq.empty());
}
int putaway(int Aa, int Bb, int T, int X[], int Y[], int W[], int S[]) {
n=T;
for(i=1;i<=T;i++)
{
v[i].first=W[i-1];
v[i].second=S[i-1];
}
sort(v+1,v+n+1);
A=Aa;B=Bb;
for(i=1;i<=A;i++)
a[i]=X[i-1];
sort(a+1,a+A+1);
for(i=1;i<=B;i++)
b[i]=Y[i-1];
sort(b+1,b+B+1);
int timp=(1<<20)-1;
if(!check(timp)) return -1;
for(int p=19;p>=0;p--)
if(check(timp-(1<<p)))
timp-=(1<<p);
return timp;
}
# | 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... |