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 <iostream>
#include <vector>
#include <set>
#include <cassert>
#include <algorithm>
#include "robots.h"
using namespace std;
const int N = 1001;
multiset<int> part[N];
int resp[N];
int putaway(int a,int b,int t,int x[],int y[],int w[],int s[]){
vector<pair<int,int>> v;
for (int i=0;i<t;i++)
v.push_back({w[i],s[i]});
sort(begin(v),end(v));
sort(x,x + a);
int ind = 0;
for (int i=0;i<t;i++){
while (ind < a and v[i].first >= x[ind])
ind++;
if (ind == a){
ind--;
while (i<t){
part[1000].insert(v[i].second);
i++;
}
break;
}
part[ind].insert(v[i].second);
}
sort(y,y + b);
for (int i=0;i<=ind;i++)
resp[i] = i;
int erased = 0;
int tm = 0;
while (erased < t){
tm++;
bool er = false;
for (int i=0;i<b;i++){
for (int j=1000;j>=0;j--){
if (part[j].size()==0)
continue;
auto u = part[j].upper_bound(y[i]);
if (u==begin(part[j]))
continue;
u = prev(u);
erased++;
er = true;
// cout<<"round "<<tm<<" from part["<<j<<"] "<<y[i]<<" erased "<<*u<<endl;
part[j].erase(u);
break;
}
}
for (int i=ind;i>=0;i--){
while (resp[i]>-1 and part[resp[i]].size()==0)
resp[i]--;
if (resp[i]==-1)
continue;
int k = resp[i];
part[k].erase(prev(end(part[k])));
er = true;
erased++;
// cout<<"round "<<tm<<" from part["<<k<<"] "<<x[i]<<" erased last"<<endl;
}
if (!er)
return -1;
// cout<<
}
return tm;
}
# | 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... |