#include "ricehub.h"
int field[10001];
int besthub(int R, int L, int X[], long long B)
{
for(int i=0; i<R; i++) field[ X[i] ]++;
int optimalGain = 0;
for(int i=1; i<=L; i++) {
long long constraint = 0;
int localGain=0;
for(int j=1; j<=L and constraint+j<=B; j++) {
if( (i-j) > 0 && field[i-j]) {constraint+=j; localGain+=field[i-j];}
if( (i+j) <= L && field[i+j] && constraint+j<=B) {constraint+=j; localGain+=field[i+j];}
}
localGain+= field[i];
if(localGain>optimalGain) optimalGain = localGain;
}
return optimalGain ;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
5060 KB |
Output is correct |
2 |
Correct |
0 ms |
5060 KB |
Output is correct |
3 |
Correct |
0 ms |
5060 KB |
Output is correct |
4 |
Correct |
0 ms |
5060 KB |
Output is correct |
5 |
Correct |
0 ms |
5060 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
5060 KB |
Output is correct |
2 |
Correct |
0 ms |
5060 KB |
Output is correct |
3 |
Correct |
0 ms |
5060 KB |
Output is correct |
4 |
Correct |
0 ms |
5060 KB |
Output is correct |
5 |
Correct |
0 ms |
5060 KB |
Output is correct |
6 |
Correct |
0 ms |
5060 KB |
Output is correct |
7 |
Correct |
0 ms |
5060 KB |
Output is correct |
8 |
Correct |
0 ms |
5060 KB |
Output is correct |
9 |
Correct |
0 ms |
5060 KB |
Output is correct |
10 |
Correct |
0 ms |
5060 KB |
Output is correct |
11 |
Incorrect |
0 ms |
5060 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
5060 KB |
Output is correct |
2 |
Correct |
16 ms |
5060 KB |
Output is correct |
3 |
Execution timed out |
1000 ms |
5060 KB |
Execution timed out |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
63 ms |
5060 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |