ํฐ์คํ ๋ฆฌ ๋ทฐ
๐จ๐ป ์ฝ๋ฉํ
์คํธ/๋ฐฑ์ค
๋ฐฑ์ค: 11054 ๊ฐ์ฅ ๊ธด ๋ฐ์ดํ ๋ ๋ถ๋ถ ์์ด
dirmathfl 2020. 7. 7. 23:43728x90
๋ฐ์ํ
๋ฌธ์
๋ฌธ์ ํ์ด
์ด ๋ฌธ์ ๋ 11053 ๊ฐ์ฅ ๊ธด ์ฆ๊ฐํ๋ ๋ถ๋ถ ์์ด, 11722 ๊ฐ์ฅ ๊ธด ๊ฐ์ํ๋ ๋ถ๋ถ ์์ด๋ฅผ ์ดํดํ๊ณ ์๋ค๋ฉด ์ฝ๊ฒ ํ ์ ์๋ค. ํน์ ์ง์ ์ ์ ํํ์์ ๋, ์ฆ๊ฐํ๋ ๋ถ๋ถ๊ณผ ๊ฐ์ํ๋ ๋ถ๋ถ์ ํฉ์ด ๊ฐ์ฅ ํฐ ๊ฒฝ์ฐ๋ฅผ ๋ฐํํ๋ฉด ๋๋ค.
์ฝ๋
from sys import stdin
if __name__ == '__main__':
n = int(stdin.readline())
nums = list(map(int, stdin.readline().split()))
forward = [1] * n
backward = [1] * n
max_len = 0
for i in range(1, n):
for j in range(i):
if nums[j] < nums[i]:
forward[i] = max(forward[i], forward[j] + 1)
if nums[n - j - 1] < nums[n - i - 1]:
backward[n - i - 1] = max(backward[n - i - 1], backward[n - j - 1] + 1)
for f_cnt, b_cnt in zip(forward, backward):
cur_len = f_cnt + b_cnt
max_len = cur_len if cur_len > max_len else max_len
print(max_len - 1)
728x90
๋ฐ์ํ
'๐จโ๐ป ์ฝ๋ฉํ ์คํธ > ๋ฐฑ์ค' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
๋ฐฑ์ค: 13398 ์ฐ์ํฉ 2 (0) | 2020.07.09 |
---|---|
๋ฐฑ์ค: 1149 RGB ๊ฑฐ๋ฆฌ (0) | 2020.07.08 |
๋ฐฑ์ค: 11057 ์ค๋ฅด๋ง ์ (0) | 2020.07.06 |
๋ฐฑ์ค: 11722 ๊ฐ์ฅ ๊ธด ๊ฐ์ํ๋ ๋ถ๋ถ ์์ด (0) | 2020.07.05 |
๋ฐฑ์ค: 11055 ๊ฐ์ฅ ํฐ ์ฆ๊ฐ ๋ถ๋ถ ์์ด (0) | 2020.07.05 |
๋๊ธ
๊ธ ๋ณด๊ดํจ
์ต๊ทผ์ ์ฌ๋ผ์จ ๊ธ
์ต๊ทผ์ ๋ฌ๋ฆฐ ๋๊ธ