# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
676518 | QwertyPi | Skyline (IZhO11_skyline) | C++14 | 1 ms | 212 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |