add 电信研发工程师考试内容.

This commit is contained in:
2022-10-28 02:37:25 +08:00
parent 2aa12fbb6e
commit 6b40f708b2
21 changed files with 289 additions and 3 deletions

21
luogu/P1216/main.py Normal file
View File

@@ -0,0 +1,21 @@
import io
import sys
sys.stdin = io.StringIO('''5
7
3 8
8 1 0
2 7 4 4
4 5 2 6 5''')
n = int(input())
nums = []
for i in range(n):
nums.append(list(map(int, input().split())))
f = [[0] * (n + 1) for _ in range(n + 1)]
for i in range(n - 1, -1, -1):
for j in range(i + 1):
f[i][j] = max(f[i + 1][j], f[i + 1][j + 1]) + nums[i][j]
print(f[0][0])