Submission #939680

#TimeUsernameProblemLanguageResultExecution timeMemory
939680LitusianoDischarging (NOI20_discharging)C++17
11 / 100
89 ms18112 KiB
#include<bits/stdc++.h> using namespace std; #define int long long signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); int n; cin>>n; vector<int> v(n); for(int& i : v) cin>>i; int s = v[0]; int last = 0; int mx = v[0]; for(int i = 1; i<n; i++){ if(v[i] <= mx){ s += mx; } else{ int tmp = (i-last) * (v[i]-mx) + v[i]; int tmp1 = (n-i)*mx + v[i]; mx = v[i]; // cerr<<tmp<<" "<<tmp1<<" "<<last<<endl; if(tmp < tmp1){ s+=tmp; } else{ s+=tmp1; last = i; } } } cout<<s<<endl; }
#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...