#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define pll pair<ll, ll>
int besthub(int n, int l, int a[], long long b)
{
// 0 1 2 3 4 5
ll mid = a[n/2];
if (n%2==0){
mid += a[n/2+1];
mid /= 2;
}
ll sum = 0, ind = -1, mx = 0;
for (ll i = n/2+1; i<n; i++){
sum += a[i];
if (sum - (i-n/2)*mid <= b){
ind = i;
mx++;
}
else {
sum -= a[i];
break;
}
}
// 24 4 2 10
b -= (sum - (ind-n/2)*mid);
ll sum2 = 0;
for (ll i = n/2; i>=0; i--){
sum2 += a[i];
if ((n/2-i+1)*mid - sum2 <= b){
mx = max(mx, ind-i+1);
}
else {
b += (a[ind] - mid);
ind--;
}
}
return mx;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
444 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
604 KB |
Output is correct |
2 |
Correct |
2 ms |
604 KB |
Output is correct |
3 |
Correct |
8 ms |
3676 KB |
Output is correct |
4 |
Correct |
9 ms |
3600 KB |
Output is correct |
5 |
Correct |
4 ms |
2908 KB |
Output is correct |
6 |
Correct |
4 ms |
2904 KB |
Output is correct |
7 |
Correct |
7 ms |
3420 KB |
Output is correct |
8 |
Correct |
7 ms |
3420 KB |
Output is correct |
9 |
Correct |
3 ms |
2904 KB |
Output is correct |
10 |
Correct |
4 ms |
2868 KB |
Output is correct |
11 |
Correct |
11 ms |
3596 KB |
Output is correct |
12 |
Correct |
8 ms |
3676 KB |
Output is correct |
13 |
Incorrect |
4 ms |
3012 KB |
Output isn't correct |
14 |
Halted |
0 ms |
0 KB |
- |