#include<bits/stdc++.h>
#include "ricehub.h"
using namespace std;
int besthub(int n, int L, int X[], long long B){
vector<long long> p(n, 0);
for(int i = 0; i < n; i ++){
if(i > 0) p[i] = p[i - 1];
p[i] += X[i];
}
int l = 0, r = n;
while(l < r){
int m = ((l + r) / 2) + 1;
/// can m ?
bool can = false;
for(int i = 0; i + m < n; i ++){
int l1 = i, r1 = i + m;
int mid = (l1 + r1) / 2;
int x = m / 2;
int y = m - (m / 2);
long long cur = x * 1ll * X[i] - (p[mid] - (l1 == 0 ? 0 : p[l1 - 1]));
cur += (p[r1] - p[mid]) - y * 1ll * X[i];
if(cur <= B) can = true;
}
if(can == true){
l = m;
}
else{
r = m - 1;
}
}
return l + 1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
768 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |