#include "ricehub.h"
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,i,p[101010],b,l,r,c,hs;
bool rct(ll aa,ll bb)
{
ll hh=0,ce=(aa+bb)/2;
hh=(p[ce]-p[ce-1])*((ce-1)-aa+1)-(p[ce-1]-p[aa-1])+
(p[bb]-p[ce])-(p[ce]-p[ce-1])*(bb-(ce+1)+1);
//cout<<hh<<" "<<aa<<" "<<bb<<"\n";
return hh<=b;
}
bool rmt(ll aa)
{
ll ii;
for(ii=1;ii+aa-1<=n;ii++)
{
if(rct(ii,ii+aa-1))
return 1;
}
return 0;
}
int besthub(int R, int L, int X[], long long B)
{
n=R;
for(i=1;i<=n;i++)
{
p[i]=p[i-1];
p[i]+=X[i-1];
}
b=B;
l=0;
r=R;
while(l<=r)
{
c=(l+r)/2;
if(rmt(c))
{
hs=c;
l=c+1;
}
else
r=c-1;
}
return hs;
}
/*
//#include "ricehub.h"
#include <stdio.h>
#include <stdlib.h>
#define MAX_R 1000000
static int R, L;
static long long B;
static int X[MAX_R];
static int solution;
inline
void my_assert(int e) {if (!e) abort();}
static void read_input()
{
int i;
my_assert(3==scanf("%d %d %lld",&R,&L,&B));
for(i=0; i<R; i++)
my_assert(1==scanf("%d",&X[i]));
my_assert(1==scanf("%d",&solution));
}
int main()
{
int ans;
read_input();
ans = besthub(R,L,X,B);
if(ans==solution)
printf("Correct.\n");
else
printf("Incorrect. Returned %d instead of %d.\n",ans,solution);
return 0;
}
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
6712 KB |
Output is correct |
2 |
Correct |
0 ms |
6712 KB |
Output is correct |
3 |
Correct |
0 ms |
6712 KB |
Output is correct |
4 |
Correct |
0 ms |
6712 KB |
Output is correct |
5 |
Correct |
0 ms |
6712 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
6712 KB |
Output is correct |
2 |
Correct |
0 ms |
6712 KB |
Output is correct |
3 |
Correct |
0 ms |
6712 KB |
Output is correct |
4 |
Correct |
0 ms |
6712 KB |
Output is correct |
5 |
Correct |
0 ms |
6712 KB |
Output is correct |
6 |
Correct |
0 ms |
6712 KB |
Output is correct |
7 |
Correct |
0 ms |
6712 KB |
Output is correct |
8 |
Correct |
0 ms |
6712 KB |
Output is correct |
9 |
Correct |
0 ms |
6712 KB |
Output is correct |
10 |
Correct |
0 ms |
6712 KB |
Output is correct |
11 |
Correct |
0 ms |
6712 KB |
Output is correct |
12 |
Correct |
0 ms |
6712 KB |
Output is correct |
13 |
Correct |
0 ms |
6712 KB |
Output is correct |
14 |
Correct |
0 ms |
6712 KB |
Output is correct |
15 |
Correct |
0 ms |
6712 KB |
Output is correct |
16 |
Correct |
0 ms |
6712 KB |
Output is correct |
17 |
Correct |
0 ms |
6712 KB |
Output is correct |
18 |
Correct |
0 ms |
6712 KB |
Output is correct |
19 |
Correct |
0 ms |
6712 KB |
Output is correct |
20 |
Correct |
0 ms |
6712 KB |
Output is correct |
21 |
Correct |
0 ms |
6712 KB |
Output is correct |
22 |
Correct |
0 ms |
6712 KB |
Output is correct |
23 |
Correct |
0 ms |
6712 KB |
Output is correct |
24 |
Correct |
0 ms |
6712 KB |
Output is correct |
25 |
Correct |
0 ms |
6712 KB |
Output is correct |
26 |
Correct |
0 ms |
6712 KB |
Output is correct |
27 |
Correct |
0 ms |
6712 KB |
Output is correct |
28 |
Correct |
0 ms |
6712 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
6712 KB |
Output is correct |
2 |
Correct |
0 ms |
6712 KB |
Output is correct |
3 |
Correct |
0 ms |
6712 KB |
Output is correct |
4 |
Correct |
0 ms |
6712 KB |
Output is correct |
5 |
Correct |
0 ms |
6712 KB |
Output is correct |
6 |
Correct |
0 ms |
6712 KB |
Output is correct |
7 |
Correct |
0 ms |
6712 KB |
Output is correct |
8 |
Correct |
0 ms |
6712 KB |
Output is correct |
9 |
Correct |
0 ms |
6712 KB |
Output is correct |
10 |
Correct |
0 ms |
6712 KB |
Output is correct |
11 |
Correct |
0 ms |
6712 KB |
Output is correct |
12 |
Correct |
0 ms |
6712 KB |
Output is correct |
13 |
Correct |
0 ms |
6712 KB |
Output is correct |
14 |
Correct |
0 ms |
6712 KB |
Output is correct |
15 |
Correct |
0 ms |
6712 KB |
Output is correct |
16 |
Correct |
0 ms |
6712 KB |
Output is correct |
17 |
Correct |
0 ms |
6712 KB |
Output is correct |
18 |
Correct |
0 ms |
6712 KB |
Output is correct |
19 |
Correct |
0 ms |
6712 KB |
Output is correct |
20 |
Correct |
0 ms |
6712 KB |
Output is correct |
21 |
Correct |
0 ms |
6712 KB |
Output is correct |
22 |
Correct |
0 ms |
6712 KB |
Output is correct |
23 |
Correct |
0 ms |
6712 KB |
Output is correct |
24 |
Correct |
0 ms |
6712 KB |
Output is correct |
25 |
Correct |
0 ms |
6712 KB |
Output is correct |
26 |
Correct |
0 ms |
6712 KB |
Output is correct |
27 |
Correct |
0 ms |
6712 KB |
Output is correct |
28 |
Correct |
0 ms |
6712 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
6712 KB |
Output is correct |
2 |
Correct |
0 ms |
6712 KB |
Output is correct |
3 |
Correct |
16 ms |
6712 KB |
Output is correct |
4 |
Correct |
16 ms |
6712 KB |
Output is correct |
5 |
Correct |
9 ms |
6712 KB |
Output is correct |
6 |
Correct |
13 ms |
6712 KB |
Output is correct |
7 |
Correct |
19 ms |
6712 KB |
Output is correct |
8 |
Correct |
16 ms |
6712 KB |
Output is correct |
9 |
Correct |
9 ms |
6712 KB |
Output is correct |
10 |
Correct |
13 ms |
6712 KB |
Output is correct |
11 |
Correct |
23 ms |
6712 KB |
Output is correct |
12 |
Correct |
19 ms |
6712 KB |
Output is correct |
13 |
Correct |
9 ms |
6712 KB |
Output is correct |
14 |
Correct |
3 ms |
6712 KB |
Output is correct |
15 |
Correct |
13 ms |
6712 KB |
Output is correct |
16 |
Correct |
16 ms |
6712 KB |
Output is correct |
17 |
Correct |
16 ms |
6712 KB |
Output is correct |
18 |
Correct |
13 ms |
6712 KB |
Output is correct |
19 |
Correct |
19 ms |
6712 KB |
Output is correct |
20 |
Correct |
23 ms |
6712 KB |
Output is correct |