Submission #139472

#TimeUsernameProblemLanguageResultExecution timeMemory
139472SortingRice Hub (IOI11_ricehub)C++14
0 / 100
67 ms740 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 7; long long b; int l, r, *x; long long prefix[N]; long long calc_sum(int from, int to){ if(from == 0){ return prefix[to]; } return prefix[to] - prefix[from - 1]; } long long find_score(int from, int to){ long long mid; if((to - from) & 1){ mid = (x[(to + from) / 2] + x[(to + from) / 2 + 1]) / 2; } else{ mid = x[(to + from) / 2]; } long long ans = ((to + from) / 2 - from + 1ll) * mid - calc_sum(from, (to + from) / 2); ans += calc_sum((to + from) / 2 + 1, to) - (to - (to + from) / 2ll) * mid; return ans; } int besthub(int _r, int _l, int *_x, long long _b){ r = _r; l = _l; x = _x; b = _b; int ans = 0; prefix[0] = x[0]; for(int i = 1; i < r; i++){ prefix[i] = x[i] + prefix[i - 1]; } for(int i = 0; i < r; i++){ int j; for(j = i; j < r && (x[j] - x[i]) <= 2 * b; j++); j--; ans = max(ans, j - i + 1); } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...