#include <bits/stdc++.h>
#include "ricehub.h"
#define ii pair<int,int>
#define ve vector
#define vi vector<int>
#define vii vector<ii>
#define pb push_back
#define fi first
#define se second
#define ll long long
#define MAX_R 1000000
#define optimise ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int besthub(int r, int l, int s[], long long b){
ll cur = b, i = s[0];
int u = 0, v = 0;
while(v < r-1 && cur-(s[v+1]-i) >= 0){
v++;
cur -= s[v]-i;
}
int mx = v-u+1;
for (int k = 1; k < r; ++k)
{
i = s[k];
cur += (v-k+1)*(s[k]-s[k-1]) - (k-u)*(s[k]-s[k-1]);
if(k > v) v = k;
while(cur < 0 && i <= v && u <= i){
if(i-s[u] < s[v]-i){
cur += s[v]-i;
v--;
} else {
cur += i-s[u];
u++;
}
}
while(v < r-1 && i-s[u] >= s[v+1]-i ){
cur += i-s[u] - (s[v+1]-i);
u++;
v++;
}
while(cur >= 0 && (u > 0 || v < r-1)){
if(v >= r-1){
if(cur - (i-s[u-1]) < 0) break;
u--;
cur -= i-s[u];
} else if(u <= 0){
if(cur - (s[v+1]-i) < 0) break;
v++;
cur -= s[v]-i;
} else if(i-s[u-1] > s[v+1]-i){
if(cur - (s[v+1]-i) < 0) break;
v++;
cur -= s[v]-i;
} else {
if(cur - (i-s[u-1]) < 0) break;
u--;
cur -= i-s[u];
}
}
mx = max(mx,v-u+1);
}
return mx;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
324 KB |
Output is correct |
3 |
Correct |
1 ms |
316 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
320 KB |
Output is correct |
6 |
Incorrect |
0 ms |
312 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
468 KB |
Output is correct |
2 |
Correct |
3 ms |
452 KB |
Output is correct |
3 |
Correct |
14 ms |
1748 KB |
Output is correct |
4 |
Correct |
12 ms |
1676 KB |
Output is correct |
5 |
Correct |
5 ms |
852 KB |
Output is correct |
6 |
Correct |
5 ms |
836 KB |
Output is correct |
7 |
Correct |
10 ms |
1384 KB |
Output is correct |
8 |
Correct |
12 ms |
1380 KB |
Output is correct |
9 |
Correct |
5 ms |
712 KB |
Output is correct |
10 |
Correct |
5 ms |
724 KB |
Output is correct |
11 |
Correct |
11 ms |
1748 KB |
Output is correct |
12 |
Incorrect |
14 ms |
1816 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |