#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
long long ma=-1;
int besthub(int R, int L, int X[], long long B){
/* if(R<=500){ ma=-1;
for(int i=0;i<R;i++){
for(int j=i;j<R;j++){
// cout<<i<<" "<<j<<endl;
vector<int>rp;
for(int k=i;k<=j;k++){
rp.push_back(X[k]);
}
int mi=(i+j)/2;
mi=X[mi];
// cout<<i<<" "<<j<<endl;
bool sw=0;
long long b=B;
for(int k=0;k<rp.size();k++){
b-=abs(mi-rp[k]);
if(b<0){
sw=1;
break;
}
//c++;
}
if(sw==0){
// cout<<i<<" "<<j<<" "<<rp.size()<<endl;
long long tam=rp.size();
ma=max(ma,tam);
}
}
}
return ma;
}
else{*/
vector<ll>T;
T.push_back(0);
for(int i=0;i<R;i++){
T.push_back(X[i]+T[T.size()-1]);
}
for(int i=0;i<R;i++){
int l,r;
l=i+1;
r=R;
while(true){
ll mi=l+(r-l)/2;
//cout<<l<<" "<<r<<" "<<ma<<" "<<mi<<endl;
if(l>r) break;
ll p=(i+mi)/2;
if((p-i)*X[p]-(T[p]-T[i])+(T[mi+1]-T[p+1])-(mi-p)*X[p]<=B){
ma=max(ma,(ll)(mi-i)+1);
if(l==mi) break;
l=mi;
}
else{
if(r==mi) break;
r=mi;
}
}
}
return ma;
//}
}
/*
#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 |
Incorrect |
5 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
256 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
384 KB |
Output is correct |
6 |
Correct |
4 ms |
256 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
4 ms |
384 KB |
Output is correct |
10 |
Correct |
4 ms |
256 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
5 ms |
384 KB |
Output is correct |
15 |
Correct |
5 ms |
384 KB |
Output is correct |
16 |
Correct |
5 ms |
384 KB |
Output is correct |
17 |
Correct |
5 ms |
384 KB |
Output is correct |
18 |
Correct |
5 ms |
384 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 |
7 ms |
384 KB |
Output is correct |
23 |
Correct |
6 ms |
512 KB |
Output is correct |
24 |
Correct |
5 ms |
384 KB |
Output is correct |
25 |
Correct |
6 ms |
384 KB |
Output is correct |
26 |
Correct |
5 ms |
384 KB |
Output is correct |
27 |
Correct |
6 ms |
512 KB |
Output is correct |
28 |
Correct |
6 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
768 KB |
Output is correct |
2 |
Correct |
8 ms |
768 KB |
Output is correct |
3 |
Correct |
30 ms |
1912 KB |
Output is correct |
4 |
Correct |
30 ms |
1912 KB |
Output is correct |
5 |
Correct |
15 ms |
1148 KB |
Output is correct |
6 |
Correct |
15 ms |
1148 KB |
Output is correct |
7 |
Correct |
27 ms |
1912 KB |
Output is correct |
8 |
Correct |
27 ms |
1912 KB |
Output is correct |
9 |
Correct |
15 ms |
1148 KB |
Output is correct |
10 |
Correct |
17 ms |
1148 KB |
Output is correct |
11 |
Correct |
31 ms |
1912 KB |
Output is correct |
12 |
Correct |
36 ms |
1912 KB |
Output is correct |
13 |
Correct |
17 ms |
1148 KB |
Output is correct |
14 |
Correct |
21 ms |
1148 KB |
Output is correct |
15 |
Correct |
26 ms |
1784 KB |
Output is correct |
16 |
Correct |
25 ms |
1784 KB |
Output is correct |
17 |
Correct |
33 ms |
1904 KB |
Output is correct |
18 |
Correct |
28 ms |
1912 KB |
Output is correct |
19 |
Correct |
38 ms |
1912 KB |
Output is correct |
20 |
Correct |
30 ms |
1912 KB |
Output is correct |