Submission #165754

#TimeUsernameProblemLanguageResultExecution timeMemory
165754HideoRice Hub (IOI11_ricehub)C++11
0 / 100
20 ms2936 KiB
#pragma GCC optimize ("O3") #pragma GCC target ("sse4") #include <bits/stdc++.h> #include "ricehub.h" //#include "grader.cpp" using namespace std; #define ll long long const int N = 1e5 + 7; int a[N], pr[N], sf[N]; int n, ans; ll mx; int solve (int l, int r){ int mid = ((l + r) >> 1) + 1; ll cost = (pr[mid] - pr[l] - (a[mid] - a[l]) * (l - 1)) + (sf[mid] - sf[r] - (a[r] - a[mid]) * (n - r)); if (cost > mx){ if (a[mid] - a[l] > a[r] - a[mid]) solve(l + 1, r); else solve(l, r - 1); } else return r - l + 1; } int besthub(int R, int L, int X[], long long B){ n = R; mx = B; for (int i = 0; i < n; i++){ a[i + 1] = X[i]; pr[i + 1] = pr[i] + i * (a[i + 1] - a[i]); } for (int i = n; i >= 1; i--) sf[i] = sf[i + 1] + (n - i) * (a[i + 1] - a[i]); return solve(1, n); }

Compilation message (stderr)

ricehub.cpp: In function 'int solve(int, int)':
ricehub.cpp:29:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...