Submission #924346

# Submission time Handle Problem Language Result Execution time Memory
924346 2024-02-08T21:22:04 Z asdfGuest Skyline (IZhO11_skyline) C++14
0 / 100
1 ms 596 KB
#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

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 time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 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 1 ms 344 KB Output is correct
8 Incorrect 0 ms 596 KB Output isn't correct
9 Halted 0 ms 0 KB -