Submission #239559

#TimeUsernameProblemLanguageResultExecution timeMemory
239559gratus907Rice Hub (IOI11_ricehub)C++17
Compilation error
0 ms0 KiB
using namespace std; long long _X[101010], _R; long long presum[101010]; long long curbest = 0, curans = 0; inline long long range_sum(int Left, int Right, int Target) { if (Left <= 0 || Right<=0 || Right>_R || Left>_R) return LLONG_MAX; int tmp = presum[Right]-presum[Left-1]; return abs(tmp - _X[Target]*(Right-Left+1)); } int besthub(int R, int L, int X[], long long B) { _R = R; for (int i = 1; i<=R; i++) { _X[i] = X[i]; presum[i] = presum[i-1]+X[i]; } for (int i = 1; i<=R; i++) { int lo = 0, hi = min(i-1,R-i)+1; while(lo+1 < hi) { int d = (lo+hi)/2; long long lsum = range_sum(i-d, i-1, i); long long rsum = range_sum(i+1, i+d, i); if (lsum+rsum <= B) lo = d; else hi = d; } long long possible_gets = 2*lo+1; if (possible_gets>=curbest) { curbest = possible_gets; curans = i; } } for (int i = 1; i<R; i++) { int len = X[i+1]-X[i]; if (len > B) continue; int lo = 0, hi = min(i-1,R-i-1)+1; while(lo+1 < hi) { int d = (lo+hi)/2; long long lsum = range_sum(i-d, i-1, i); long long rsum = range_sum(i+2, i+d+1, i); if (lsum+rsum+len <= B) lo = d; else hi = d; } long long possible_gets = 2*lo+2; if (possible_gets>=curbest) { curbest = possible_gets; curans = i; } } return curbest; }

Compilation message (stderr)

ricehub.cpp: In function 'long long int range_sum(int, int, int)':
ricehub.cpp:8:62: error: 'LLONG_MAX' was not declared in this scope
     if (Left <= 0 || Right<=0 || Right>_R || Left>_R) return LLONG_MAX;
                                                              ^~~~~~~~~
ricehub.cpp:8:62: note: suggested alternative: '__LONG_MAX__'
     if (Left <= 0 || Right<=0 || Right>_R || Left>_R) return LLONG_MAX;
                                                              ^~~~~~~~~
                                                              __LONG_MAX__
ricehub.cpp:10:12: error: 'abs' was not declared in this scope
     return abs(tmp - _X[Target]*(Right-Left+1));
            ^~~
ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:22:26: error: 'min' was not declared in this scope
         int lo = 0, hi = min(i-1,R-i)+1;
                          ^~~
ricehub.cpp:45:26: error: 'min' was not declared in this scope
         int lo = 0, hi = min(i-1,R-i-1)+1;
                          ^~~