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<int,int>> v;
int a[M], b[M];
int siza, sizb;
bool sol(int mid) {
int 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());
int l = 1, r = T + 5;
int ans = -1;
while(l < r) {
int 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... |