Submission #1095681

#TimeUsernameProblemLanguageResultExecution timeMemory
1095681MtSakaRice Hub (IOI11_ricehub)C++17
100 / 100
11 ms1628 KiB
#include"bits/stdc++.h" #include "ricehub.h" #define overload(a,b,c,d,...) d #define rep1(a) for(ll _=0;_<(ll)a;++_) #define rep2(i,a) for(ll i=0;i<(ll)(a);++i) #define rep3(i,a,b) for(ll i=(ll)(a);i<(ll)(b);++i) #define rep(...) overload(__VA_ARGS__,rep3,rep2,rep1)(__VA_ARGS__) #define rrep1(i,a) for(ll i=(ll)(a)-1;i>=0;--i) #define rrep2(i,a,b) for(ll i=(ll)(b)-1;i>=(ll)(a);--i) #define rrep(...) overload(__VA_ARGS__,rrep2,rrep1)(__VA_ARGS__) #define all(x) (x).begin(),(x).end() #define rall(x) (x).rbegin(),(x).rend() #define pb push_back #define eb emplace_back using namespace std; using ll=long long; using ull=unsigned long long; using i128=__int128_t; using ld=long double; using vi=vector<int>; using vl=vector<ll>; template<typename T,typename U>inline bool chmin(T&a,const U&b){return (a>b?a=b,true:false);} template<typename T,typename U>inline bool chmax(T&a,const U&b){return (a<b?a=b,true:false);} int besthub(int r, int l, int x[], ll b){ vector<ll>sum(r+1); rep(i,r)sum[i+1]=sum[i]+x[i]; ll right=0; int ans=0; rep(left,r){ while(right<r){ ll mid=(left+right+1)/2; ll cost=-((left+right+1)&1)*x[mid]-sum[mid]+sum[left]+sum[right+1]-sum[mid]; if(cost<=b)right++; else break; } chmax(ans,right-left); if(right==r)break; } 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...