#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define pll pair<ll, ll>
ll p[100005];
int besthub(int n, int k, int a[], long long b)
{
for (ll i = 0; i<n; i++){
p[i+1] = p[i] + a[i];
}
ll l = 0, r = 0, mx = 0;
while (r < n){
ll mid = (l + r)/2;
ll sum = (p[r+1] - p[mid+1]) - a[mid]*(r-mid) + a[mid]*(mid-l) - (p[mid+1] - p[l+1]);
if (sum <= b){
mx = max(mx, r-l+1);
r++;
}
else {
l++;
}
}
return mx;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2396 KB |
Output is correct |
2 |
Incorrect |
0 ms |
2488 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
0 ms |
2488 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Incorrect |
0 ms |
2396 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |