제출 #744356

#제출 시각아이디문제언어결과실행 시간메모리
744356vjudge1쌀 창고 (IOI11_ricehub)C++17
100 / 100
17 ms2516 KiB
#include "ricehub.h" #include <bits/stdc++.h> using namespace std; const int maxR = 1e5 + 5; #define ll long long ll dp[maxR]; bool check(int window, int R, long long B) { for (int m = (window + 1) / 2; m + (window / 2) <= R; ++m) { ll rightdis = dp[m + (window / 2)] - dp[m]; ll leftdis = dp[m - 1 + (window % 2 == 0)] - dp[m - (window / 2) + (window % 2 == 0) - 1]; ll cost = rightdis - leftdis; if (cost <= B) return true; } return false; } int besthub(int R, int L, int X[], long long B) { dp[0] = 0; for (int i = 0; i < R; ++i) dp[i + 1] = dp[i] + X[i]; int l = 0, r = R + 10, ans = -1; while (l <= r) { int mid = (l + r) / 2; //cout << l << " " << mid << " " << r << "\n"; if (check(mid, R, B)) { l = mid + 1; ans = mid; } else r = mid - 1; } //cout << ans; 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...