Submission #466991

#TimeUsernameProblemLanguageResultExecution timeMemory
466991AMO5Discharging (NOI20_discharging)C++17
0 / 100
1093 ms15956 KiB
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define ld long double #define all(x) x.begin(),x.end() #define sz(x) (int)x.size() #define dbg if(0) #define BUG(x) dbg cerr << (#x) << " is " << (x) << endl const int mxn = (int)1e6+5; const int64_t inf = 5e18; //subtask 2 void solve(){ int n; cin>>n; vector<int64_t>a(n); for(auto &x:a) { cin>>x; } vector<int64_t>dp(n); for(int i=0; i<n; i++){ dp[i] = inf; for(int j=i; j>=0; j--){ int len = n-j; int64_t curr = (int64_t)1*len*(a[i]) + (j>0?dp[j]:(int64_t)0); dbg cerr<<i<<" "<<j<<" "<<curr<<"\n"; dp[i]=min(dp[i],curr); } } cout<<dp.back()<<"\n"; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); // int t=1; cin>>t; while(t--) solve(); return 0; }
#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...