# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
715577 | 2023-03-27T08:50:05 Z | cbup | Rice Hub (IOI11_ricehub) | C++14 | 2 ms | 468 KB |
#include<bits/stdc++.h> using namespace std; long long findcost(int st,int en,int mid,vector<long long> &prefixSum,int *x){ return (mid-st)*x[mid]*1LL-(prefixSum[mid]-prefixSum[st]) + (prefixSum[en+1]-prefixSum[mid+1])-(en-mid)*x[mid]*1LL; } long long besthub(int n,int l,int x[],long long b){ long long cost,ans=1; int mid,st,en,len,low=0,high=n-1,m,check = 0; vector<long long> prefixSum(n+1,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; while(low<=high){ check = 0; len = (low+high)/2; for(st=0;st<n-len;st++){ en = st+len; mid = (st+en)/2; cost = findcost(st,en,mid,prefixSum,x); if(cost <= b){ ans = max(ans,en-st+1LL); check = 1; } //cout<<st<<" "<<en<<" "<<cost<<endl; } if(check)high = len-1; else low = len+1; } return ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Incorrect | 0 ms | 212 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Incorrect | 0 ms | 212 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 468 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |