This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/*
░░░░██████████████████
░░▄███████▀▀▀▀▀▀███████▄
░▐████▀▒mohammad▒▀██████▄
░███▀▒▒▒▒alaa▒▒▒▒▒▒▀█████
░▐██▒▒▒alwrawrah▒▒▒▒▒████▌
░▐█▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████▌
░░█▒▄▀▀▀▀▀▄▒▒▄▀▀▀▀▀▄▒▐███▌
░░░▐░░░▄▄░░▌▐░░░▄▄░░▌▐███▌
░▄▀▌░░░▀▀░░▌▐░░░▀▀░░▌▒▀▒█▌
░▌▒▀▄░░░░▄▀▒▒▀▄░░░▄▀▒▒▄▀▒▌
░▀▄▐▒▀▀▀▀▒▒▒▒▒▒▀▀▀▒▒▒▒▒▒█
░░░▀▌▒▄██▄▄▄▄████▄▒▒▒▒█▀
░░░░▄██████████████▒▒▐▌
░░░▀███▀▀████▀█████▀▒▌
░░░░░▌▒▒▒▄▒▒▒▄▒▒▒▒▒▒▐
░░░░░▌▒▒▒▒▀▀▀▒▒▒▒▒▒▒▐
*/
#include<bits/stdc++.h>
#include "robots.h"
using namespace std;
typedef long long ll ;
const ll oo = 1e13 ;
const double PI = acos(-1) ;
const ll M = 1e9 + 7 ;
vector<int> v;
int ans =0 ;
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
sort(X , X + A) ;
sort(W , W + T) ;
if(X[A - 1] < W[T - 1])return -1;
else{
int ls = 0;
int x = 1 , lx = 0 ;
for(int i = 0 ; i < A ; ++i){
if(X[i] < W[0])continue;
auto it = (lower_bound(W , W + T , X[i]) - W);
v.push_back(it - ls);
ls = it;
}
ans = v.back() ;
for(int i = v.size() - 2 ; i >= 0 ; --i){
if(v[i] > ans){
if(lx){
int xx = lx ;
v[i] -= ans ;
lx -= min(lx , v[i]);
v[i] -= min(v[i] , xx);
if(v[i]){
lx = (x + 1) - v[i] % (x + 1);
ans += (v[i] + x) / (x + 1);
}
}else if(ans < (v[i] - ans + x) / (x + 1) + ans){
lx = (x + 1) - (v[i] - ans) % (x + 1) ;
ans = (v[i] - ans + x) / (x + 1) + ans;
}
}else{
lx += ans - v[i];
}
x++;
}
}
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... |