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;
const int MAXN = 1e6 + 10;
int n, m, t;
int x[MAXN], y[MAXN];
pair<int, int> v[MAXN];
int bb();
bool test(int val);
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
n = A, m = B, t = T;
for(int i = 0; i < t; i++)
v[i] = make_pair(W[i], S[i]);
for(int i = 0; i < n; i++)
x[i] = X[i];
for(int i = 0; i < m; i++)
y[i] = Y[i];
sort(v, v + t);
sort(x, x + n);
sort(y, y + m);
reverse(v, v + t);
reverse(x, x + n);
reverse(y, y + m);
return bb();
}
int bb(){
int ini = 1, fim = t;
if(!test(t + 1)) return -1;
while(ini != fim){
int mid = (ini + fim) >> 1;
if(test(mid)) fim = mid;
else ini = mid + 1;
}
return ini;
}
bool test(int val){
int naoPego = 0;
for(int i = 0; i < n; i++){
if(v[naoPego].first >= x[i]) return 0;
naoPego += val;
if(naoPego >= t) return 1;
}
return 0;
}
# | 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... |