제출 #924346

#제출 시각아이디문제언어결과실행 시간메모리
924346asdfGuest스카이라인 (IZhO11_skyline)C++14
0 / 100
1 ms596 KiB
#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;
}

컴파일 시 표준 에러 (stderr) 메시지

skyline.cpp: In function 'int main()':
skyline.cpp:22:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
skyline.cpp:24:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |         scanf("%d", &a[i]);
      |         ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...