제출 #715560

#제출 시각아이디문제언어결과실행 시간메모리
715560cbup쌀 창고 (IOI11_ricehub)C++14
17 / 100
462 ms262144 KiB
#include<bits/stdc++.h> using namespace std; long long besthub(int n,int l,int x[],long long b){ long long cost,ans=0; int mid; vector<long long> prefixSum(l,0); for(int i=1;i<=n;i++)prefixSum[i] = prefixSum[i-1]+x[i-1]; //for(int i=1;i<=n;i++)cout<<prefixSum[i]<<" "; cout<<endl; for(int st=0;st<n;st++){ for(int en=st;en<n;en++){ mid = (st+en)/2; cost = (mid-st)*x[mid]-(prefixSum[mid]-prefixSum[st]) + (prefixSum[en+1]-prefixSum[mid+1])-(en-mid)*x[mid]; if(cost <= b)ans = max(ans,en-st+1LL); //cout<<st<<" "<<en<<" "<<cost<<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...