#include <bits/stdc++.h>
#include "ricehub.h"
#define f first
#define s second
using namespace std;
int besthub(int R, int L, int X[], long long B)
{
int n = R;
int a[n];
for(int i = 0;i < n;i++)
a[i] = X[i];
int ans = 0;
int l = 0, r = 0;
long long t = 0;
while(r < n && t + a[r] - a[0] <= B) {
t += (a[r] - a[0]);
++r;
++ans;
}
for(int i = 1;i < n;i++) {
if(i > r) {
l = r = i;
t = 0;
while(r < n && t + a[r] - a[i] <= B) {
t += (a[r] - a[i]);
++r;
}
}
else {
t -= (r - i + 1) * (a[i] - a[i - 1]);
t += (i - l) * (a[i] - a[i - 1]);
while(t > B)
t -= (a[i] - a[l++]);
while(r < n - 1 && l < i && a[r + 1] - a[i] <= a[l] - a[i]) {
t -= (a[l] - a[i]);
l++;
r++;
t += (a[r] - a[i]);
}
}
ans = max(ans, r - l + 1);
}
return ans;
}
// signed main()
// {
// ios_base::sync_with_stdio(false);
// cin.tie(0);
// cout.tie(0);
// int tt = 1;
// //cin >> tt;
// while(tt--) {
// int n, k;
// long long x;
// cin >> n >> k >> x;
// int a[n];
// for(int i = 0;i < n;i++)
// cin >> a[i];
// cout << besthub(n, k, a, x);
// }
// return 0;
// }
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |