제출 #788772

#제출 시각아이디문제언어결과실행 시간메모리
788772Ronin13Rice Hub (IOI11_ricehub)C++17
100 / 100
19 ms2520 KiB
#include "ricehub.h" #include <bits/stdc++.h> #define ll long long #define ull unsigned ll #define f first #define s second #define pii pair<int, int> #define pll pair<ll,ll> #define pb push_back #define epb emplace_back using namespace std; int besthub(int n, int l, int X[], long long B){ ll pref[n + 1]; pref[0] = 0; for(int i = 1; i <= n; i++){ pref[i] = pref[i - 1] + (ll)X[i - 1]; } int mx = 0; for(int i = 1; i <= n; i++){ int l = 0, r = n + 1; while(l + 1 < r){ int mid = (l + r) / 2; int x = (mid + 1) / 2; int y = mid - x; if(i < x) { r = mid; continue; } if(i + y > n){ r = mid; continue; } ll a = (ll)x * (ll)X[i - 1] - (pref[i] - pref[i - x]); ll b = pref[i + y] - pref[i] - (ll)X[i - 1] * (ll)y; if(a + b <= B) l = mid; else r = mid; } //cout << l << ' '; mx = max(mx, l); } return mx; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...