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 Max = 1e6 + 5;
const int M = 5e4 + 5;
typedef long long ll;
vector<pair<ll,ll>> v;
ll a[M], b[M];
int siza, sizb;
bool sol(ll mid) {
ll cnt = 0;
int indx = siza-1;
// cout << mid << 'p' << endl;
for(int i = v.size()-1; i >= 0; i--) {
// cout << v[i].first << ' ' << i << ' ' << indx << ' ' << a[indx] << 'o' << endl;
if(indx < 0) return false;
if(v[i].first >= a[indx]) {
return false;
}
else {
cnt++;
// cout << cnt << 'i' << endl;
if(cnt == mid) {
cnt = 0; indx--;
}
}
}
//cout << 'Y' << endl;
return true;
}
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
for(int i = 0; i < A; i++) a[i] = X[i];
for(int i = 0; i < B; i++) b[i] = Y[i];
siza = A; sizb = B;
sort(a,a+A); sort(b,b+B);
for(int i = 0; i < T; i++) {
v.push_back({W[i],0});
}
sort(v.begin(),v.end());
ll l = 0, r = 10000000000;
ll ans = -1;
while(l < r) {
ll mid = (l+r)/2;
if(sol(mid) == true) {
r = mid-1;
ans = mid;
}
else {
l = mid+1;
}
}
return ans;
}
# | 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... |