페이지

1965번: 상자넣기

https://www.acmicpc.net/problem/1965


#include<stdio.h>
#include<algorithm>
using namespace std;
int n, dp[1000], sz;
int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        int a, pos;
        scanf("%d", &a);
        pos = lower_bound(dp, dp + sz, a) - dp;
        dp[pos] = a;
        if (pos == sz) sz++;
    }
    printf("%d", sz);
    return 0;
}

댓글 없음 :

댓글 쓰기