# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
949624 | amirhoseinfar1385 | Growing Vegetables is Fun 4 (JOI21_ho_t1) | C++17 | 23 ms | 8076 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
const long long maxn=200000+10;
long long n,all[maxn];
long long ps[maxn],suf[maxn],dpps[maxn],dpsuf[maxn];
void vorod(){
cin>>n;
for(long long i=1;i<=n;i++){
cin>>all[i];
}
}
void pre(){
for(long long i=1;i<=n;i++){
ps[i]=ps[i-1];
ps[i]+=max(0ll,all[i-1]-all[i]+1);
}
for(long long i=n;i>=1;i--){
suf[i]=suf[i+1];
suf[i]+=max(0ll,all[i+1]-all[i]+1);
}
}
void solve(){
long long res=1e15;
for(long long i=1;i<=n;i++){
//cout<<i<<" "<<ps[i]<<" "<<suf[i]<<endl;
long long fres=max(ps[i],suf[i]);
res=min(res,fres);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |