#include "ricehub.h"
#include <bits/stdc++.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));
}
using namespace std;
int besthub(int R,int L,int X[], long long B){
// cout<<"a"<<endl;
long long 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 or b>=0){
// cout<<i<<" "<<j<<" "<<rp.size()<<endl;
long long tam=rp.size();
ma=max(ma,tam);
}
}
}
return ma;
}
/*
int main()
{
int ans;
read_input();
// cout<<"a"<<endl;
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;
}*/
Compilation message
ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:37:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int k=0;k<rp.size();k++){
~^~~~~~~~~~
ricehub.cpp: At global scope:
ricehub.cpp:13:13: warning: 'void read_input()' defined but not used [-Wunused-function]
static void read_input()
^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
256 KB |
Output is correct |
4 |
Correct |
8 ms |
256 KB |
Output is correct |
5 |
Correct |
8 ms |
256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
6 ms |
256 KB |
Output is correct |
3 |
Correct |
6 ms |
256 KB |
Output is correct |
4 |
Correct |
6 ms |
384 KB |
Output is correct |
5 |
Correct |
6 ms |
256 KB |
Output is correct |
6 |
Correct |
6 ms |
256 KB |
Output is correct |
7 |
Correct |
6 ms |
256 KB |
Output is correct |
8 |
Correct |
7 ms |
368 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 |
256 KB |
Output is correct |
12 |
Correct |
5 ms |
256 KB |
Output is correct |
13 |
Correct |
5 ms |
256 KB |
Output is correct |
14 |
Correct |
5 ms |
384 KB |
Output is correct |
15 |
Correct |
7 ms |
384 KB |
Output is correct |
16 |
Correct |
3 ms |
256 KB |
Output is correct |
17 |
Correct |
6 ms |
256 KB |
Output is correct |
18 |
Correct |
5 ms |
256 KB |
Output is correct |
19 |
Correct |
7 ms |
384 KB |
Output is correct |
20 |
Correct |
6 ms |
384 KB |
Output is correct |
21 |
Correct |
103 ms |
256 KB |
Output is correct |
22 |
Correct |
130 ms |
384 KB |
Output is correct |
23 |
Correct |
138 ms |
368 KB |
Output is correct |
24 |
Correct |
139 ms |
384 KB |
Output is correct |
25 |
Correct |
134 ms |
376 KB |
Output is correct |
26 |
Correct |
134 ms |
384 KB |
Output is correct |
27 |
Correct |
117 ms |
256 KB |
Output is correct |
28 |
Correct |
117 ms |
256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
384 KB |
Output is correct |
2 |
Correct |
13 ms |
360 KB |
Output is correct |
3 |
Correct |
589 ms |
504 KB |
Output is correct |
4 |
Correct |
595 ms |
412 KB |
Output is correct |
5 |
Correct |
104 ms |
376 KB |
Output is correct |
6 |
Correct |
101 ms |
384 KB |
Output is correct |
7 |
Correct |
571 ms |
256 KB |
Output is correct |
8 |
Correct |
575 ms |
256 KB |
Output is correct |
9 |
Correct |
106 ms |
256 KB |
Output is correct |
10 |
Correct |
116 ms |
376 KB |
Output is correct |
11 |
Correct |
333 ms |
376 KB |
Output is correct |
12 |
Correct |
344 ms |
376 KB |
Output is correct |
13 |
Correct |
754 ms |
376 KB |
Output is correct |
14 |
Correct |
757 ms |
504 KB |
Output is correct |
15 |
Correct |
117 ms |
256 KB |
Output is correct |
16 |
Correct |
133 ms |
380 KB |
Output is correct |
17 |
Correct |
415 ms |
384 KB |
Output is correct |
18 |
Correct |
443 ms |
504 KB |
Output is correct |
19 |
Correct |
778 ms |
384 KB |
Output is correct |
20 |
Correct |
743 ms |
384 KB |
Output is correct |
21 |
Execution timed out |
1091 ms |
384 KB |
Time limit exceeded |
22 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1094 ms |
700 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |