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 "ricehub.h"
#include <bits/stdc++.h>
#define PB push_back
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long i64;
int n;
int bound; //inclusive
i64 b;
vector<int> x;
bool feasible(int coor){
i64 cost = 0;
for(int i = 0; i < n; i++){
cost += ((i64) x[i] - coor);
if(cost > b) return 0;
}
return 1;
}
int solve(){
int l = 1, r = bound;
while (l + 1 < r){
int m = (l + r) >> 1;
if (feasible(m)){
l = m;
}
else r = m - 1;
}
return l;
}
int besthub(int R, int L, int X[], long long B){
for (int i = 0; i < R; i++) x.PB(X[i]);
bound = L;
n = R;
b = B;
return solve();
}
# | 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... |