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;
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
const int INF = (int)1e9;
vector<pii> weak, small, toy;
bool work(int i, int j, int type){
if(type==0) return weak[i].fi>toy[j].fi;
return small[i].se>toy[j].se;
}
bool chk(int x){
reverse(all(toy)); int j = sz(weak)-1, cnt = 0; bool ok = true;
for(int i = 0; i < sz(toy); i++){
ok&=(work(j,i,0));
if(cnt==x) j--, cnt=0;
cnt++;
}
reverse(all(toy));
return ok;
}
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
for(int i = 0; i < A; i++) weak.pb({X[i],INF});
for(int i = 0; i < B; i++) small.pb({INF,Y[i]});
for(int i = 0; i < T; i++) toy.pb({W[i],S[i]});
sort(all(weak)), sort(all(small)), sort(all(toy));
if(A==0){
if(work(0,0,1) and work(1,1,1)) return 1;
if(work(1,0,1) and work(1,1,1)) return 2;
return -1;
}
else if(B==0){
if(!work(A-1,T-1,0)) return -1;
int l = (T+A-1)/A, r = T;
while(l<r){
int mid = (l+r)/2;
if(chk(mid)) r=mid;
else l=mid+1;
}
return l;
}
else{
if(work(0,0,0) and work(0,1,1)) return 1;
if(work(0,0,1) and work(0,1,0)) return 1;
if(work(0,0,0) and work(0,1,0)) return 2;
if(work(0,0,1) and work(0,1,1)) return 2;
return -1;
}
}
# | 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... |