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;
typedef long long ll;
ll dp[500000];
ll arr[500000];
int main(){
cin.tie(0);
ios_base::sync_with_stdio(0);
int n;
cin>>n;
dp[0]=0;
for (int i = 1; i<=n; i++){
cin>>arr[i];
ll mxv = arr[i];
dp[i]=1e18;
for (int x = i-1; x>=0; x--){
mxv=max(mxv,arr[x]);
dp[i]=min(dp[i],(n-x)*mxv+dp[x]);
}
//cout<<dp[i]<<'\n';
}
cout<<dp[n]<<'\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |