Submission #462369

#TimeUsernameProblemLanguageResultExecution timeMemory
462369Khizri쌀 창고 (IOI11_ricehub)C++17
100 / 100
28 ms1480 KiB
#include "ricehub.h" #include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define F first #define S second #define INF 1e18 #define all(v) (v).begin(),(v).end() #define rall(v) (v).rbegin(),(v).rend() #define pii pair<int,int> #define pll pair<ll,ll> #define OK cout<<"Ok"<<endl; #define MOD (ll)(1e9+7) #define endl "\n" const int mxn=1e5+5; ll sum[mxn]; ll f(int ind){ if(ind<0){ return 0; } return sum[ind]; } ll cal(int l,int r,int arr[]){ int m=(l+r)/2; ll k=0; k+=arr[m]*(m-l+1)-(sum[m]-f(l-1)); k+=sum[r]-f(m-1)-arr[m]*(r-m+1); return k; } int besthub(int n, int dis, int arr[], long long k) { sum[0]=arr[0]; for(int i=1;i<n;i++){ sum[i]=sum[i-1]+arr[i]; } int ans=0; for(int i=0;i<n;i++){ int l=i,r=n-1,ind=0; while(l<=r){ int m=(l+r)/2; if(cal(i,m,arr)<=k){ ind=m; l=m+1; } else{ r=m-1; } } ans=max(ans,ind-i+1); } 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...