# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1059225 | vjudge1 | Robots (IOI13_robots) | C++17 | 0 ms | 0 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>
#define ll long long
using namespace std;
vector<pair<int,int>> Tw;
int a, t;
vector<int> x;
int binary(int l, int r){
int n;
while(l <= r){
n = (l+r)/2;
if(bcheck(n)){
r = n-1;
}else{
l = n+1;
}
}
return l;
}
bool bcheck(int n){
int pos=0,cnt=n,toys_cnt=0;
for(int i=0; i < t; i++){
if(Tw[i].first < x[pos]){
cnt--;
toys_cnt++;
}
if(cnt == 0){
cnt = n;
pos++;
}
if(pos == a)break;
}
return toys_cnt == t;
}
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
a = A; t = T;
for(int i=0; i < A; i++){
x.push_back(X[i]);
}
sort(x.rbegin(),x.rend());
for(int i=0; i < T; i++){
Tw.push_back({W[i],S[i]});
}
sort(Tw.rbegin(),Tw.rend());
int ans=binary(0,T);
if(ans > T)ans = -1;
return ans;
}