I have successfully written the code that works and is less than 256 bytes. But when I'm taking the inputs for the values of elements in the n lines, I'm not able to take them in the same line. I have to press enter every time, producing an NZEC error. I would like to know how I could fix that.
t=int(raw_input())
while t:
n=int(raw_input())
a=[]
for i in range(n):
a.append([])
for j in range(i+1):
a[i].append(int(raw_input()))
for i in range(n-1)[::-1]:
for j in range(i+1):
a[i][j]+=max(a[i+1][j],a[i+1][j+1])
print a[0][0]
t-=1
created
last reply
- 1
reply
- 365
views
- 2
users