Submission #655219

#TimeUsernameProblemLanguageResultExecution timeMemory
655219PanTkdRice Hub (IOI11_ricehub)C++14
0 / 100
142 ms364 KiB
#include "ricehub.h" #include <iostream> #include <cmath> typedef long long ll; using namespace std; int besthub(int R, int L, int X[], long long B) { for(ll i = R;i>=1;i--){ ll cost = 0; ll med = (i/2); ll l = i/2; ll r = (i+1)/2; for(ll j = 0;j<i;j++){ cost += abs(X[med]-X[j]); } if(cost<=B) return i; for(ll j = i;j<R;j++){ cost -= abs(X[j-i]-X[med]); cost += abs(X[i]-X[med]); cost += (X[med+1]-X[med])*(l-r); med+=2; if(cost<=B)return i; } } return 1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...