# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1060625 | vjudge1 | Robots (IOI13_robots) | C++17 | 0 ms | 0 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<bits/stdc++.h>
using namespace std;
typedef pair<int, int> ii;
typedef long long ll;
typedef pair<long long, long long> pll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
#define pb push_back
#define fi first
#define se second
#define whole(v) v.begin(), v.end()
#define rwhole(v) v.rbegin(), v.rend()
#define inf INT_MAX/2
#define fro front
int x[], y[];
vector<ii> z;
bool f(int n){
int j = 0;
int i = 0;
int cnt = 0;
priority_queue<int> q;
for(j; j < x.size(); ++j){
while(z[i].fi >= x[j]){
q.pb(z[i].se);
++i;
cnt++;
}
if(j > 0)
cnt -= n;
}
vector<int> ne;
for(int k = 0; k < cnt; ++k){
ne.pb(q.top());
q.pop();
}
sort(whole(ne));
i = 0;
j = 0;
for(j; j < y.size(); ++j){
int cn = 0;
while(ne[i] < y[j]){
cn++;
cnt--;
++i;
if(cn == n){
break;
}
}
}
if(cnt > 0){
return 0;
}else{
return 1;
}
}
int putaway(int a, int b, int t, int X[], int Y[], int W[], int S[]){
x = X; y = Y; w = W; s = S;
sort(x, x+a);
sort(y, y+b);
reverse(x, x+a);
for(int i = 0; i < t; ++i){
z.pb(ii(w[i], s[i]));
if(w[i] >= x[0] && s[i] >= y[0]){
return -1;
}
}
sort(rwhole(z));
int lo = 0;
int hi = t + 2;
while(hi - lo > 1){
int mi = lo + (hi - lo) / 2;
if(f(mi)){
hi = mi;
}else{
lo = mi;
}
}
return hi;
}