Submission #1008785

#TimeUsernameProblemLanguageResultExecution timeMemory
1008785Rolo678Discharging (NOI20_discharging)C++14
36 / 100
1053 ms21076 KiB
#include<bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<long long>a(n+1); for(int i = 1;i<=n;i++)cin >>a[i]; vector<long long>dp(n+1,1e15); dp[0] = 0; for(int i = 1;i<=n;i++) { long long mx= 0; for(int j = i;j>=1;j--) { mx = max(a[j],mx); dp[i] = min(dp[j-1] + (n-j+1)*mx,dp[i]); } } cout << dp[n] << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...