# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
924335 | 2024-02-08T21:03:55 Z | asdfGuest | 스카이라인 (IZhO11_skyline) | C++14 | 1 ms | 500 KB |
#include <iostream> #include <algorithm> using namespace std; int n, a[10000 + 2] = {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 = a[i + 0] - a[i + 1] + a[i + 2]; a[i] -= m; a[i + 1] -= m; a[i + 2] -= m; cost += 7 * m; cost += 5 * f(i, 2); } cost += 7 * f(i, 3); cost += 5 * f(i, 2); cost += 3 * f(i, 1); } printf("%d\n", cost); system("pause"); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 500 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Incorrect | 1 ms | 348 KB | Output isn't correct |
9 | Halted | 0 ms | 0 KB | - |