# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
982592 | kwongweng | Robots (IOI13_robots) | C++17 | 2982 ms | 35728 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 long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long double ld;
typedef vector<vector<ll>> vll;
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define ROF(i, a, b) for(int i = a; i >= b; i--)
#define pb push_back
#define ms memset
#define fi first
#define se second
/*
Solution is binary search
*/
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(i,0,T){
if (W[i]>=X[A-1] && S[i]>=Y[B-1]) return -1;
}
int l = 0, r = T+1;
vii w(T+A);
FOR(i,0,T) w[i] = {W[i],S[i]};
FOR(i,T,T+A) w[i] = {X[i-T],0};
sort(w.begin(), w.end());
while (r-l>1){
int mid = (l+r)/2;
priority_queue<int> p;
FOR(i,0,T+A){
if (w[i].se > 0){
p.push(w[i].se); continue;
}
int cnt = 0;
while (!p.empty() && cnt < mid){
p.pop(); cnt++;
}
}
vii rem;
while (!p.empty()){
rem.pb({p.top(),1});
p.pop();
}
FOR(i,0,B) rem.pb({Y[i],0});
sort(rem.begin(), rem.end());
priority_queue<int> q;
FOR(i,0,rem.size()){
if (rem[i].se>0){
q.push(rem[i].fi); continue;
}
int cnt = 0;
while (!q.empty() && cnt < mid){
q.pop(); cnt++;
}
}
if (q.empty()){
r=mid;
}else{
l=mid;
}
}
return r;
}
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... |