Submission #1199440

#TimeUsernameProblemLanguageResultExecution timeMemory
1199440AMel0nRice Hub (IOI11_ricehub)C++20
100 / 100
9 ms2380 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define FOR(i,N) for(ll i = 0; i < N; i++) #define all(x) (x).begin(), (x).end() #define F first #define S second #include "ricehub.h" ll N; vector<ll> ps; vector<ll> V; ll cost(ll l, ll r) { ll m = (l + r) / 2; // sum of the distance between all the coords from rice fields [l, r] to m return (ps[r+1] - ps[m+1]) - V[m] * (r-m) + V[m] * (m-l+1) - (ps[m+1] - ps[l]); } int besthub(int R, int L, int X[], ll B) { ::N = R; ps.resize(N+1); V.resize(N+1); FOR(i,N) {ps[i+1] = ps[i] + X[i]; V[i] = X[i];} ll res = 0, l = 0; for (ll r = 0; r < N; r++) { // 1 indexed indices of the ricehubs ll c = cost(l, r); while (c > B) { l++; c = cost(l, r); } res = max(res, r - l + 1); } return res; } // signed main() { // cin.tie(0); ios::sync_with_stdio(false); // }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...