제출 #1316365

#제출 시각아이디문제언어결과실행 시간메모리
1316365husseinjuanda쌀 창고 (IOI11_ricehub)C++20
100 / 100
8 ms696 KiB
#include "ricehub.h" #include <bits/stdc++.h> #define ll long long using namespace std; int besthub(int R, int L, int X[], long long B) { int low = 1; int top = R; int ns = 0; while(low <= top){ ll mid = (low + top)/2; ll mn = 1e18; ll bel = 0; ll aft = 0; for(int i = 0; i < mid/2; i++){ bel += X[i]; } for(int i = mid/2; i < mid; i++){ aft += X[i]; } int mdl = mid/2; int l = 0; mn = min(mn, X[mdl]*(mid/2) - bel + aft - X[mdl]*((mid+1)/2)); for(int i = mid; i < R; i++){ bel -= X[l]; l++; bel += X[mdl]; aft -= X[mdl]; mdl++; aft += X[i]; mn = min(mn, X[mdl]*(mid/2) - bel + aft - X[mdl]*((mid+1)/2)); } if(mn <= B){ low = mid+1; ns = mid; }else{ top = mid-1; } } return ns; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...