# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
924346 | asdfGuest | Skyline (IZhO11_skyline) | C++14 | 1 ms | 596 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 <iostream>
#include <algorithm>
using namespace std;
int n, a[10000 + 3] = {0};
inline int f(int idx, int len) {
int m = 1000000000;
for (int i = 0; i < len; i++)
m = min(m, a[idx + i]);
for (int i = 0; i < len; i++)
a[idx + i] -= m;
return m;
}
int main(void) {
scanf("%d", &n);
for (int i = 0; i < n; i++)
scanf("%d", &a[i]);
int cost = 0;
for (int i = 0; i < n; i++) {
if (a[i] <= a[i + 2] && a[i + 1] > a[i + 2]) {
int m = min(a[i], a[i + 1] - a[i + 2]);
a[i + 0] -= m;
a[i + 1] -= m;
cost += 5 * m;
}
cost += 7 * f(i, 3);
cost += 5 * f(i, 2);
cost += 3 * f(i, 1);
//printf("%d cost %d\n", i, cost);
}
printf("%d\n", cost);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |