ํฐ์คํ ๋ฆฌ ๋ทฐ
๐ฉ๐ป๐ป ๋ฌธ์
โ๐ป ํ์ด
๐จ Python3
import sys
def calculate(n):
if n == 1:
return values[0][0]
max_values = [[values[0][0]]]
idx = 0
for i in range(1, n):
val = []
for j in range(0, i+1):
if j-1<0:
max_val = max_values[i-1][j]
elif j>i-1:
max_val = max_values[i-1][j-1]
else:
max_val = max(max_values[i-1][j], max_values[i-1][j-1])
val.append(max_val+values[i][j])
max_values.append(val)
return max(max_values[n-1])
if __name__ == "__main__":
n = int(sys.stdin.readline())
values = []
for i in range(n):
values.append(list(map(int, sys.stdin.readline().split())))
max_value = calculate(n)
print(max_value)
728x90
'dev > algorithm' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
BOJ / 2004๋ฒ / ์กฐํฉ 0์ ๊ฐ์ [Go][Python3] (0) | 2020.11.05 |
---|---|
BOJ / 1676๋ฒ / ํฉํ ๋ฆฌ์ผ 0์ ๊ฐ์ [Go][Python3] (0) | 2020.11.04 |
BOJ / 1149๋ฒ / RGB๊ฑฐ๋ฆฌ [Go] [Python3] (0) | 2020.08.04 |
BOJ / 9461๋ฒ / ํ๋๋ฐ ์์ด [Go] [Python3] (0) | 2020.08.03 |
BOJ / 1904๋ฒ / 01ํ์ผ [Go] [Python3] (0) | 2020.08.02 |
๋๊ธ
๊ธ ๋ณด๊ดํจ
์ต๊ทผ์ ๋ฌ๋ฆฐ ๋๊ธ
TAG
- MongoDB
- Algorithm
- ๋งฅ๋ถํ๋ก
- ๋ถํ ์ ๋ณต
- ๋งฅ๋ถ ์ ๊ทธ๋ ์ด๋
- ๋งฅ๋ถ
- Golang
- dfs
- ๋ฐฑ์ค
- ์๊ฐ๊ต์ฒด
- ์ด๋ถํ์
- ballet
- ๋ชฝ๊ณ ๋๋น
- ์๊ณ ๋ฆฌ์ฆ
- ์คํ
- baekjoon
- dp
- AWS
- ์๋ฐ
- python3
- go
- ๋ฐ๋
- java
- BFS
- BOJ
- Macbook pro 2012 mid 13
- ํ๋ก์ด๋์์ฌ
- ๋ธ๋ฃจํธํฌ์ค
- ํด์๋งต
- ํ
- Total
- Today
- Yesterday