# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
743026 | 2023-05-17T07:29:14 Z | vjudge1 | Rice Hub (IOI11_ricehub) | C++17 | 0 ms | 0 KB |
#include "ricehub.h" #include<bits/stdc++.h> using namespace std ; using ll = long long ; using pii = pair<ll , ll> ; const int N = 1e6+5 ; ll qs[N] , ans = 0; deque<pii> dq ; ll besthub(int R, int L, int X[], long long B) { for(int i=0;i<R;i++){ qs[X[i]]++ ; } for(int i=1;i<=L;i++){ qs[i] += qs[i-1] ; } dq.push_back({0 , -1}); for(int i=0;i<=L;i++){ while(!dq.empty() && dq.front().second < i - B){ dq.pop_front(); } ans = max(ans , qs[i] - dq.front().first) ; while(!dq.empty() && dq.back().first >= qs[i]){ dq.pop_back(); } dq.push_back({qs[i] , i}); } return ans ; }