페이지

2846번: 오르막길

https://www.acmicpc.net/source/4436038


$O(n)$


#include<cstdio>
int n, p = 1000, t, x, r;
int main() {
    for (scanf("%d", &n); n--;) {
        scanf("%d", &x);
        if (p >= x) t = x;
        if (x - t>r) r = x - t;
        p = x;
    }
    printf("%d", r);
    return 0;
}

댓글 없음 :

댓글 쓰기