#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] ]++;
long long optimalGain = 0;
for(int i=0; i<L; i++) {
long long localGain =0, constraint = 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];}
}
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 |
Incorrect |
0 ms |
5060 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
5060 KB |
Output is correct |
2 |
Incorrect |
0 ms |
5060 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
5060 KB |
Output is correct |
2 |
Correct |
13 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 |
53 ms |
5060 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |