Submission #676518

#TimeUsernameProblemLanguageResultExecution timeMemory
676518QwertyPiSkyline (IZhO11_skyline)C++14
0 / 100
1 ms212 KiB
#include <bits/stdc++.h> using namespace std; int a[301]; int main(){ int n; cin >> n; for(int i = 0; i < n; i++){ cin >> a[i]; } int ans = 0; for(int i = 0; i <= n - 3; i++){ int h = min(min(a[i], a[i + 1]), a[i + 2]); a[i] -= h; a[i + 1] -= h; a[i + 2] -= h; ans += h * 7; } for(int i = 0; i <= n - 2; i++){ int h = min(a[i], a[i + 1]); a[i] -= h; a[i + 1] -= h; ans += h * 5; } for(int i = 0; i <= n - 1; i++){ int h = a[i]; a[i] -= h; ans += h * 3; } cout << ans << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...