#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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,teste = 0;
while( (l >= 0 && b >= m-x[l]) || ( r < n && b >= x[r]-m) ){
if(m-x[l] <= x[r]-m){
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... |