์๊ฐ ์ ํ | ๋ฉ๋ชจ๋ฆฌ ์ ํ | ์ ๋ต ๋น์จ |
1 ์ด | 256 MB | 64.883% |
https://www.acmicpc.net/problem/11722
๊ฐ์ฅ ๊ธด ์ฆ๊ฐํ๋ ๋ถ๋ถ์์ด๊ณผ ๊ฐ์๋ฌธ์ ์ด๋ค.
๊ฐ์ฅ ๊ธด ์ฆ๊ฐํ๋ ๋ถ๋ถ์์ด์ 0 →n ๋ฐฉํฅ์ผ๋ก ์ํํ๋ค๋ฉด,
๊ฐ์ฅ ๊ธด ๊ฐ์ํ๋ ๋ถ๋ถ์์ด์์๋ n →0 ๋ฐฉํฅ์ผ๋ก ์ํํ๋ค.
๊ฐ๋จํ ๋ฐฉํฅ๋ง ๋ฐ๊ฟํ์๋ค.
๋ฉ๋ชจ๋ฆฌ | ์๊ฐ |
1120 KB | 0 ms |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | #include<cstdio> using namespace std; int n, arr[1005], dp[1005], ans; int main() { scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", &arr[i]); } for (int i = n-1; i >= 0; i--) { int max = 0; for (int j = n-1; j > i; j--) { if (arr[j] < arr[i]) { if (max < dp[j]) max = dp[j]; } } dp[i] = max + 1; ans = dp[i] > ans ? dp[i] : ans; } printf("%d", ans); return 0; } | cs |
'๐ฅ PS(Problem Solving) ๐ฅ > BOJ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[BOJ] #1021 ํ์ ํ๋ ํ (0) | 2020.01.11 |
---|---|
[BOJ] #11052 ์นด๋ ๊ตฌ๋งคํ๊ธฐ (0) | 2020.01.10 |
[BOJ] #11053 ๊ฐ์ฅ ๊ธด ์ฆ๊ฐํ๋ ๋ถ๋ถ์์ด (0) | 2019.12.16 |
[BOJ] #9205 ๋งฅ์ฃผ ๋ง์๋ฉด์ ๊ฑธ์ด๊ฐ๊ธฐ (0) | 2019.10.15 |
[BOJ] #1012 ์ ๊ธฐ๋ ๋ฐฐ์ถ (0) | 2019.10.14 |
๋๊ธ