#include <bits/stdc++.h>
#include "ricehub.h"
using namespace std;
#define pb push_back
#define fi first
#define se second
#define ll long long
const ll MAX=1e5+10;
ll n, l, b, pref[MAX], t[MAX];
bool spr(ll x){
for(ll i=1; i<=n-x+1; i++){
ll mid=(i+i+x-1)/2;
ll lewo=pref[mid-1]-pref[i-1];
ll prawo=pref[i+x-1]-pref[mid];
if((mid-i)*t[mid]-lewo+prawo-(i+x-1-mid)*t[mid]<=b)
return true;
}
return false;
}
int besthub(int R, int L, int X[], ll B){
n=R, l=L, b=B;
for(ll i=1; i<=n; i++){
pref[i]=X[i-1];
t[i]=pref[i];
pref[i]+=pref[i-1];
}
ll pocz=1, kon=n, sr, wynik=1;
while(pocz<=kon){
sr=(pocz+kon)/2;
if(spr(sr))
pocz=sr+1, wynik=sr;
else
kon=sr-1;
}
return wynik;
}
/*ll main(){
ios_base::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
}*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
0 ms |
204 KB |
Output is correct |
11 |
Correct |
0 ms |
204 KB |
Output is correct |
12 |
Correct |
0 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
0 ms |
204 KB |
Output is correct |
16 |
Correct |
0 ms |
204 KB |
Output is correct |
17 |
Correct |
0 ms |
204 KB |
Output is correct |
18 |
Correct |
0 ms |
204 KB |
Output is correct |
19 |
Correct |
0 ms |
204 KB |
Output is correct |
20 |
Correct |
0 ms |
204 KB |
Output is correct |
21 |
Correct |
1 ms |
204 KB |
Output is correct |
22 |
Correct |
1 ms |
204 KB |
Output is correct |
23 |
Correct |
1 ms |
204 KB |
Output is correct |
24 |
Correct |
1 ms |
204 KB |
Output is correct |
25 |
Correct |
0 ms |
204 KB |
Output is correct |
26 |
Correct |
1 ms |
204 KB |
Output is correct |
27 |
Correct |
1 ms |
204 KB |
Output is correct |
28 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
0 ms |
332 KB |
Output is correct |
20 |
Correct |
1 ms |
332 KB |
Output is correct |
21 |
Correct |
1 ms |
332 KB |
Output is correct |
22 |
Correct |
1 ms |
332 KB |
Output is correct |
23 |
Correct |
1 ms |
332 KB |
Output is correct |
24 |
Correct |
1 ms |
332 KB |
Output is correct |
25 |
Correct |
1 ms |
332 KB |
Output is correct |
26 |
Correct |
1 ms |
332 KB |
Output is correct |
27 |
Correct |
1 ms |
332 KB |
Output is correct |
28 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
604 KB |
Output is correct |
2 |
Correct |
3 ms |
588 KB |
Output is correct |
3 |
Correct |
11 ms |
2172 KB |
Output is correct |
4 |
Correct |
12 ms |
3240 KB |
Output is correct |
5 |
Correct |
6 ms |
1568 KB |
Output is correct |
6 |
Correct |
7 ms |
1612 KB |
Output is correct |
7 |
Correct |
10 ms |
2944 KB |
Output is correct |
8 |
Correct |
11 ms |
2976 KB |
Output is correct |
9 |
Correct |
6 ms |
1548 KB |
Output is correct |
10 |
Correct |
6 ms |
1552 KB |
Output is correct |
11 |
Correct |
15 ms |
3304 KB |
Output is correct |
12 |
Correct |
13 ms |
3228 KB |
Output is correct |
13 |
Correct |
8 ms |
1624 KB |
Output is correct |
14 |
Correct |
8 ms |
1612 KB |
Output is correct |
15 |
Correct |
10 ms |
2508 KB |
Output is correct |
16 |
Correct |
9 ms |
2508 KB |
Output is correct |
17 |
Correct |
10 ms |
2872 KB |
Output is correct |
18 |
Correct |
11 ms |
2884 KB |
Output is correct |
19 |
Correct |
11 ms |
3160 KB |
Output is correct |
20 |
Correct |
12 ms |
3140 KB |
Output is correct |