Submission #784147

#TimeUsernameProblemLanguageResultExecution timeMemory
784147gagik_2007Rice Hub (IOI11_ricehub)C++17
100 / 100
10 ms2496 KiB
#include "ricehub.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define ff first #define ss second ll ttt; const ll INF=1e18; const ll MOD=1e9+7; const ll N=200007; ll n,m,k; ll a[N]; int besthub(int R, int L, int X[], ll B){ n=R; m=L; for(int i=0;i<n;i++){ a[i]=X[i]; } k=B; int l=0,r=0; int ans=0; ll curval=0; int mid=0; while(l<n&&r<n){ if(curval<=k){ ans=max(ans,r-l+1); r++; if((l+r)%2==0){ mid++; } curval+=abs(a[mid]-a[r]); } else{ l++; if((l+r)%2==0){ mid++; } curval-=abs(a[mid]-a[l-1]); } // cout<<l<<" "<<r<<": "<<curval<<endl; } 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...