Submission #302435

#TimeUsernameProblemLanguageResultExecution timeMemory
302435UserIsUndefinedRice Hub (IOI11_ricehub)C++14
68 / 100
1039 ms896 KiB
#include "ricehub.h" #include <bits/stdc++.h> using namespace std; int besthub(int R, int L, int X[], long long B) { int low = 0; int high = R*2; while(low < high){ int mid = (high+low)/2; long long sum = 0; long long now = mid/2; long long pluss = mid - mid/2 - 1; long long mines = mid - (pluss + 1); int good = false; for (int i = now ; i + pluss < R ; i++){ long long sum = 0; for (int j = i - mines ; j <= i + pluss ; j++){ sum+= llabs(X[j] - X[i]); } if (sum <= B){ low = mid + 1; good = true; break; } } if (good)continue; high = mid - 1; } int best = low - 1; for (int i = max(best - 5 , 0) ; i <= min(R , best + 5) ; i++){ long long pluss = i - i/2 - 1; long long mines = i - (pluss + 1); int good = false; for (int j = i/2 ; j + pluss < R ; j++){ long long sum = 0; for (int f = j - mines ; f <= j + pluss ; f++){ sum+= llabs(X[f] - X[j]); } if (sum <= B){ best = i; good = true; break; } } } return best; }

Compilation message (stderr)

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:19:19: warning: unused variable 'sum' [-Wunused-variable]
   19 |         long long sum = 0;
      |                   ^~~
ricehub.cpp:69:14: warning: variable 'good' set but not used [-Wunused-but-set-variable]
   69 |          int good = false;
      |              ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...