#include "ricehub.h"
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define f first
#define s second
#define pii pair<int, int>
#define pll pair<ll,ll>
#define pb push_back
#define epb emplace_back
using namespace std;
int besthub(int n, int l, int X[], long long B){
ll pref[n + 1];
pref[0] = 0;
for(int i = 1; i <= n; i++){
pref[i] = pref[i - 1] + X[i - 1];
}
int mx = 0;
for(int i = 1; i <= n; i++){
int l = 0, r = n;
while(l + 1 < r){
int mid = (l + r) / 2;
int x = (mid + 1) / 2;
int y = mid - x;
if(i < x) {
r = mid;
continue;
}
if(i + y > n){
r = mid;
continue;
}
ll a = (ll)x * (ll)X[i - 1] - (pref[i] - pref[i - x]);
ll b = pref[i + y] - pref[i] - (ll)X[i - 1] * (ll)y;
if(a + b <= B) l = mid;
else r = mid;
}
//cout << l << ' ';
mx = max(mx, l);
}
return mx;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
360 KB |
Output is correct |
3 |
Incorrect |
0 ms |
312 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
308 KB |
Output is correct |
3 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
596 KB |
Output is correct |
2 |
Correct |
3 ms |
576 KB |
Output is correct |
3 |
Incorrect |
16 ms |
2508 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |