#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int besthub(int N, int L, int A[], long long B) {
vector<ll> p(N + 1);
p[0] = 0;
for (ll i = 1; i <= N; i++) {
p[i] = A[i - 1];
p[i] += p[i - 1];
}
ll ans = 0;
for (ll i = 1; i <= N; i++) {
ll left = i, right = N;
while (left <= right) {
ll middle = (left + right) / 2;
ll median = (i + middle) / 2;
ll sum = (p[left + 1] - p[median]) - (left + 1 - median) * A[median - 1] +
(median - (i - 1)) * A[median - 1] - (p[median] - p[i - 1]);
if (sum <= B) {
ans = max(ans, middle - i + 1);
left = middle + 1;
} else {
right = middle - 1;
}
}
}
return ans;
}
// int main() {
// ios_base::sync_with_stdio(0);
// cin.tie(0);
// cout.tie(0);
// ll R, L;
// cin >> R >> L;
// ll X[R];
// for (ll i = 0; i < R; i++) {
// cin >> X[i];
// }
// ll B;
// cin >> B;
// cout << besthub(R, L, X, B) << "\n";
// }
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
600 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |