# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1202610 | Marco_Escandon | Robots (IOI13_robots) | C++20 | 0 ms | 0 KiB |
#include "robot.h"
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using vll=vector<ll>;
using pll=pair<ll,ll>;
using vpll=vector<pll>;
#define S second
#define F first
vll v[50005];
int putaway(int a, int b, int t, int X[], int Y[], int W[], int S[]) {
vpll sa={},sb={};
vll ca(a,0),cb(b,0);
sort(X,X+a);
for(int i=0;i<a;i++)sa.push_back({X[i]-1,i});
///*
for(int i=0;i<t;i++){
auto u1=lower_bound(sa.begin(),sa.end(),pll{W[i],0LL});
if(u1!=sa.end()){
ca[(*u1).S]++;
}
}
ll p=0,f=t+1;
while(abs(p-f)!=1){
ll m=(p+f)/2;
ll ok=0;
vll auxa=ca;
for(int i=0;i+1<a;i++){
if(auxa[i]>m){
auxa[i+1]+=auxa[i]-m;
auxa[i]=m;
}
}
if(auxa[a-1]<=m)f=m;
else p=m;
}
//*/
return f;
}