๋ฌธ์
https://www.acmicpc.net/problem/11054
ํ์ด
# ๋ฐฑ์ค 11054๋ฒ ๋ฌธ์ - ๊ฐ์ฅ ๊ธด ๋ฐ์ดํ ๋ ๋ถ๋ถ ์์ด
n = int(input())
arr = list(map(int, input().split()))
dp_increase = [1] * (n)
dp_decrease = [1] * (n)
for i in range(1, n):
for j in range(i):
if arr[i] > arr[j] and dp_increase[i] <= dp_increase[j]:
dp_increase[i] = dp_increase[j] + 1
for i in range(n-1, -1, -1):
for j in range(i, n):
if arr[i] > arr[j] and dp_decrease[i] <= dp_decrease[j]:
dp_decrease[i] = dp_decrease[j] + 1
for i in range(n):
dp_increase[i] = dp_increase[i] + dp_decrease[i] - 1
print(max(dp_increase))
LIS ์ ๋น์ทํ ๋ฌธ์ ์ด์ง๋ง ๊ฒฝ์ฐ๋ฅผ ์ฆ๊ฐํ๋ ๋ถ๋ถ ์์ด๊ณผ ๊ฐ์ํ๋ ๋ถ๋ถ์์ด ๋๊ฐ์ง๋ก ๋๋์ด์ ๊ณ์ฐํด์ผ ํ๋ค.
'๐๏ธ Algorithm > ๐ฉ ๋ฐฑ์ค' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
๐ฉ [๋ฐฑ์ค] [Python] [Gold5] 13023๋ฒ_ABCDE (0) | 2023.05.11 |
---|---|
๐ฉ [๋ฐฑ์ค] [Python] [Gold3] 1238๋ฒ_ํํฐ (1) | 2023.05.09 |
๐ฉ [๋ฐฑ์ค] [Python] [Gold4] 14500๋ฒ_ํ ํธ๋ก๋ฏธ๋ ธ (1) | 2023.05.08 |
๐ฉ [๋ฐฑ์ค] [Python] [Silver2] 1535๋ฒ_์๋ (2) | 2023.05.05 |
๐ฉ [๋ฐฑ์ค] [Python] [Gold3] 2252๋ฒ_์ค ์ธ์ฐ๊ธฐ (1) | 2023.05.04 |