Submission #28786

#TimeUsernameProblemLanguageResultExecution timeMemory
28786NikeforRice Hub (IOI11_ricehub)C++98
0 / 100
1000 ms5060 KiB
#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, 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 ;
}

Compilation message (stderr)

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:9:23: warning: left operand of comma operator has no effect [-Wunused-value]
         for(int j=1; j<=L, constraint+j<=B; j++) {
                       ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...