# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
758322 | KN200711 | 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>
# define ll long long
# define fi first
# define se second
using namespace std;
int main() {
int N;
scanf("%d", &N);
vector<int> arr(N);
for(int i=0;i<N;i++) scanf("%d", &arr[i]);
int ans = 0;
for(int i=0;i<N;i++) {
if(i == 0) {
ans += 3 * arr[i];
} else {
if(arr[i-1] >= arr[i]) ans += 2 * arr[i];
else ans += 2 * arr[i] + (arr[i] - arr[i - 1]);
}
}
printf("%d\n", ans);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |