Submission #584690

#TimeUsernameProblemLanguageResultExecution timeMemory
584690KanaifuRice Hub (IOI11_ricehub)C++17
0 / 100
3 ms1236 KiB
#include <bits/stdc++.h> #include "ricehub.h" using namespace std; int besthub(int R, int L, int X[], long long B) { long long prefix[100001]; prefix[0] = X[0]; for (int i=1; i<R; i++) { long long add = X[i]; prefix[i] = prefix[i-1] + add; } long long cost = 0; int leng = 1; long long l = 0, r = 1; while (r < R) { long long med = (l+r)/2; long long val = X[med]; cost = 0; if (med != l) { cost += (val)*(med-l)-prefix[med-1]; } if (med != r) { cost += prefix[r] - prefix[med] - (r-med)*(val); } if (cost <= B) { leng = max(leng, (int)(r - l + 1)); r++; } else { l++; r++; } } return leng; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...