Submission #1045636

#TimeUsernameProblemLanguageResultExecution timeMemory
1045636ezzzaySkyline (IZhO11_skyline)C++14
0 / 100
0 ms440 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define ff first #define ss second #define pb push_back const int N=3e5+5; vector<int>ans; int a[N]; signed main(){ int n; cin>>n; for(int i=1;i<=n;i++){ cin>>a[i]; } int k=0; for(int i=1;i<=n-2;i++){ int h=min({a[i],a[i+1],a[i+2]}); k+=h*7; a[i]-=h; a[i+1]-=h; a[i+2]-=h; } for(int i=1;i<=n-1;i++){ int h=min(a[i],a[i+1]); k+=h*5; a[i]-=h; a[i+1]-=h; } for(int i=1;i<=n;i++){ k+=a[i]*3; } cout<<k; }
#Verdict Execution timeMemoryGrader output
Fetching results...