제출 #1124166

#제출 시각아이디문제언어결과실행 시간메모리
1124166njoop쌀 창고 (IOI11_ricehub)C++17
17 / 100
0 ms328 KiB
#include <bits/stdc++.h> #define ll long long using namespace std; int n; vector<ll> arr, pre; ll cost(ll k) { ll mnco = 1e18; for(int i=k; i<=n; i++) { ll st = i-k+1, mid = st+(k+1)/2-1; ll left = (arr[mid]*(mid-st+1))-(pre[mid]-pre[st-1]); ll right = (pre[i]-pre[mid])-(arr[mid]*(i-mid)); mnco = min(mnco, left+right); } return mnco; } int besthub(int R, int L, int X[], long long B) { n=R; arr.assign(R+10, 0); pre.assign(R+10, 0); for(int i=1; i<=R; i++) { arr[i] = X[i-1]; pre[i] = pre[i-1] + arr[i]; } ll l=1, r=R; while(l < r) { ll mid = (l+r)/2; if(cost(mid) > B) { r = mid; } else { l = mid+1; } } return l-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...