#include<algorithm>
#include"ricehub.h"
using namespace std;
long long Sum[100005];
long long getCost(int st, int dr, int X[])
{
int poz=(st+dr)/2;
long long rez=-1LL*Sum[poz]+Sum[dr]-Sum[poz];;
if(st>0)
rez+=Sum[st-1];
if((dr-st+1)%2==1)
rez+=X[poz];
return rez;
}
int besthub(int N, int L, int X[], long long B)
{
Sum[0]=X[0];
for(int i=1; i<=N; i++)
Sum[i]=Sum[i-1]+X[i];
int st=0;
int rez=0;
for(int i=0; i<N; i++)
{
if(getCost(st,i,X)>B)
st++;
rez=max(rez,i-st+1);
}
return rez;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
256 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
256 KB |
Output is correct |
4 |
Correct |
4 ms |
256 KB |
Output is correct |
5 |
Correct |
4 ms |
256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
256 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
256 KB |
Output is correct |
4 |
Correct |
4 ms |
256 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
4 ms |
256 KB |
Output is correct |
7 |
Correct |
4 ms |
256 KB |
Output is correct |
8 |
Correct |
5 ms |
256 KB |
Output is correct |
9 |
Correct |
4 ms |
256 KB |
Output is correct |
10 |
Correct |
4 ms |
384 KB |
Output is correct |
11 |
Correct |
4 ms |
256 KB |
Output is correct |
12 |
Correct |
4 ms |
256 KB |
Output is correct |
13 |
Correct |
4 ms |
256 KB |
Output is correct |
14 |
Correct |
4 ms |
256 KB |
Output is correct |
15 |
Correct |
4 ms |
256 KB |
Output is correct |
16 |
Correct |
4 ms |
384 KB |
Output is correct |
17 |
Correct |
4 ms |
256 KB |
Output is correct |
18 |
Correct |
4 ms |
384 KB |
Output is correct |
19 |
Correct |
4 ms |
256 KB |
Output is correct |
20 |
Correct |
5 ms |
256 KB |
Output is correct |
21 |
Correct |
4 ms |
256 KB |
Output is correct |
22 |
Correct |
4 ms |
256 KB |
Output is correct |
23 |
Correct |
4 ms |
256 KB |
Output is correct |
24 |
Correct |
5 ms |
384 KB |
Output is correct |
25 |
Correct |
5 ms |
384 KB |
Output is correct |
26 |
Correct |
6 ms |
256 KB |
Output is correct |
27 |
Correct |
4 ms |
256 KB |
Output is correct |
28 |
Correct |
5 ms |
256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
4 ms |
256 KB |
Output is correct |
3 |
Correct |
4 ms |
256 KB |
Output is correct |
4 |
Correct |
6 ms |
256 KB |
Output is correct |
5 |
Correct |
4 ms |
256 KB |
Output is correct |
6 |
Correct |
4 ms |
256 KB |
Output is correct |
7 |
Correct |
5 ms |
256 KB |
Output is correct |
8 |
Correct |
5 ms |
256 KB |
Output is correct |
9 |
Correct |
4 ms |
256 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
5 ms |
256 KB |
Output is correct |
13 |
Correct |
5 ms |
256 KB |
Output is correct |
14 |
Correct |
4 ms |
256 KB |
Output is correct |
15 |
Correct |
5 ms |
256 KB |
Output is correct |
16 |
Correct |
5 ms |
384 KB |
Output is correct |
17 |
Correct |
4 ms |
256 KB |
Output is correct |
18 |
Correct |
5 ms |
256 KB |
Output is correct |
19 |
Correct |
5 ms |
384 KB |
Output is correct |
20 |
Correct |
5 ms |
384 KB |
Output is correct |
21 |
Correct |
5 ms |
384 KB |
Output is correct |
22 |
Correct |
5 ms |
384 KB |
Output is correct |
23 |
Correct |
5 ms |
384 KB |
Output is correct |
24 |
Correct |
5 ms |
384 KB |
Output is correct |
25 |
Correct |
6 ms |
384 KB |
Output is correct |
26 |
Correct |
6 ms |
384 KB |
Output is correct |
27 |
Correct |
5 ms |
384 KB |
Output is correct |
28 |
Correct |
6 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
512 KB |
Output is correct |
2 |
Correct |
7 ms |
512 KB |
Output is correct |
3 |
Correct |
24 ms |
1536 KB |
Output is correct |
4 |
Correct |
23 ms |
1408 KB |
Output is correct |
5 |
Correct |
13 ms |
1280 KB |
Output is correct |
6 |
Correct |
12 ms |
1280 KB |
Output is correct |
7 |
Correct |
26 ms |
2304 KB |
Output is correct |
8 |
Correct |
23 ms |
2304 KB |
Output is correct |
9 |
Correct |
12 ms |
1152 KB |
Output is correct |
10 |
Correct |
13 ms |
1152 KB |
Output is correct |
11 |
Correct |
28 ms |
2552 KB |
Output is correct |
12 |
Correct |
26 ms |
2560 KB |
Output is correct |
13 |
Correct |
14 ms |
1272 KB |
Output is correct |
14 |
Correct |
14 ms |
1272 KB |
Output is correct |
15 |
Correct |
20 ms |
1920 KB |
Output is correct |
16 |
Correct |
20 ms |
2048 KB |
Output is correct |
17 |
Correct |
23 ms |
2304 KB |
Output is correct |
18 |
Correct |
25 ms |
2344 KB |
Output is correct |
19 |
Correct |
24 ms |
2400 KB |
Output is correct |
20 |
Correct |
25 ms |
2560 KB |
Output is correct |