Submission #1095413

#TimeUsernameProblemLanguageResultExecution timeMemory
1095413TitanicXDzzRice Hub (IOI11_ricehub)C++14
100 / 100
16 ms2664 KiB
#include "ricehub.h" #include<bits/stdc++.h> using namespace std; long long dp[100010]; int besthub(int n, int q, int a[], long long b) { for(int i=1;i<=n;i++) dp[i]=dp[i-1]+a[i-1]; int l=1; int r=n; while(l!=r){ int mid=(l+r+1)/2; long long mini=LLONG_MAX; if(mid%2==0){ for(int i=1;i<=n-mid+1;i++){ int m=i+mid/2; mini=min(mini,dp[i+mid-1]-dp[m-1]*2+dp[i-1]); } } if(mid%2==1){ for(int i=1;i<=n-mid+1;i++){ int m=i+mid/2; mini=min(mini,dp[i+mid-1]-dp[m]-dp[m-1]+dp[i-1]); } } if(mini<=b){ l=mid; } else r=mid-1; } return l; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...