#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1e9+5;
int besthub(int n, int L, int x[], ll b)
{
int m, l = n/2-1, r = n/2;
if(n%2 == 1)m = x[n/2];
else m = (x[n/2]+x[n/2-1])/2;
int ans = 0;
while( (l >= 0 && b >= m-x[l]) || ( r < n && b >= x[r]-m) ){
int lv = INF, rv = INF;
if(l >= 0)lv = m-x[l];
if(r < n)rv = x[r]-m;
if(lv <= rv){
b -= m-x[l];
l--;
}else{
b -= x[r]-m;
r++;
}
ans++;
}
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... |