Skip to content

Instantly share code, notes, and snippets.

@rubyu
Created May 20, 2019 08:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rubyu/44109d4b19b88783fab673dd9a94d016 to your computer and use it in GitHub Desktop.
Save rubyu/44109d4b19b88783fab673dd9a94d016 to your computer and use it in GitHub Desktop.
#!/bin/python3
import math
import os
import random
import re
import sys
if __name__ == '__main__':
a = int(input().strip())
for i in range(a):
b = int(input().strip())
arr = []
for j in range(b):
c = list(map(int, input().rstrip().split()))
arr.append(c)
for j in range(0, b-1):
arr[j+1][0] += arr[j][0]
for k in range(1, j+1):
arr[j+1][k] += max(arr[j][k-1], arr[j][k])
arr[j+1][j+1] += arr[j][j]
print(max(arr[-1]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment