Submission #123087

#TimeUsernameProblemLanguageResultExecution timeMemory
123087khulegubRice Hub (IOI11_ricehub)C++14
0 / 100
5 ms760 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...