Submission #747499

#TimeUsernameProblemLanguageResultExecution timeMemory
747499ToxtaqDischarging (NOI20_discharging)C++17
9 / 100
1071 ms1048576 KiB
#include<bits/stdc++.h> using namespace std; int n; vector<int>v; vector<vector<int>>max_table; long long rec(int indx){ long long res = 1e18; if(indx == n + 1)return 0; for(int i = indx;i <= n;++i){ res = min(res, (long long)(n - indx + 1) * max_table[indx][i] + rec(i + 1)); } return res; } int main() { cin >> n; v.resize(n + 1); max_table.assign(n + 1, vector<int>(n + 1)); for(int i = 1;i <= n;++i)cin >> v[i]; for(int i = 1;i <= n;++i){ int mx = -1e9; for(int j = i;j <= n;++j){ mx = max(mx, v[j]); max_table[i][j] = mx; } } cout << rec(1); }
#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...