Problem p03162 (python)

Fixed submission:
n=int(input())
lst=[]
for i in range(n):
  a,b,c=map(int,input().split())
  lst.append([a,b,c])
C=[]
for i in range(n):
    C.append([float('inf')]*3)
C[0][0]=lst[0][0]
C[0][1]=lst[0][1]
C[0][2]=lst[0][2]
D=[0,1,2]
for i in range(n-1):
  for j in [0,1,2]:
    del D[j]
    C[i+1][j]=max(C[i][D[0]]+lst[i+1][j],C[i][D[1]]+lst[i+1][j])
    D=[0,1,2]
print(max(C[n-1]))

Buggy submission (verdict: Runtime Error):
n=int(input())
lst=[]
for i in range(n):
  a,b,c=map(int,input().split())
  lst.append([a,b,c])
C=[[float('inf')]*3]*n
C[0][0]=lst[0][0]
C[0][1]=lst[0][1]
C[0][2]=lst[0][2]
D=[0,1,2]
d=D
for i in range(n-1):
  for j in d:
    D=d
    D.remove(j)
    C[i+1][j]=max(C[i][D[0]],C[i][D[1]])
print(max(C[n-1]))

Buggy submission (verdict: Runtime Error):
n=int(input())
lst=[]
for i in range(n):
  a,b,c=map(int,input().split())
  lst.append([a,b,c])
C=[[float('inf')]*3]*n
C[0][0]=lst[0][0]
C[0][1]=lst[0][1]
C[0][2]=lst[0][2]
D=[0,1,2]
d=D
for i in range(n-1):
  for j in d:
    D=d
    D.remove(j)
    C[i+1][j]=C[i][D[0]]+lst[i][D[0]]
    for k in range(1,len(D)):
      if C[i][D[k]]+lst[i][D[k]]>C[i+1][j]:
        C[i+1][j]=C[i][D[k]]+lst[i][D[k]]
print(max(C[n-1]))

Buggy submission (verdict: Runtime Error):
n=int(input())
lst=[]
for i in range(n):
  a,b,c=map(int,input().split())
  lst.append([a,b,c])
C=[[float('inf')]*3]*n
C[0][0]=lst[0][0]
C[0][1]=lst[0][1]
C[0][2]=lst[0][2]
D=[0,1,2]
d=D
for i in range(n-1):
  for j in d:
    D=d
    D.remove(j)
    C[i+1][j]=C[i][D[0]]+lst[i][D[0]]
    for k in range(1,len(e)):
      if C[i][D[k]]+lst[i][D[k]]>C[i+1][j]:
        C[i+1][j]=C[i][D[k]]+lst[i][D[k]]
print(max(C[n-1]))

Buggy submission (verdict: Runtime Error):
n=int(input())
lst=[]
for i in range(n):
  a,b,c=map(int,input().split())
  lst.append([a,b,c])
C=[[float('inf')]*3]*n
C[0][0]=lst[0][0]
C[0][1]=lst[0][1]
C[0][2]=lst[0][2]
D=[0,1,2]
d=D
for i in range(n-1):
  for j in d:
    D=d
    e=D.remove(j)
    C[i+1][j]=C[i][e[0]]+lst[i][e[0]]
    for k in range(1,len(e)):
      if C[i][e[k]]+lst[i][e[k]]>C[i+1][j]:
        C[i+1][j]=C[i][e[k]]+lst[i][e[k]]
print(max(C[n-1]))

Buggy submission (verdict: Runtime Error):
n=int(input())
lst=[]
for i in range(n):
  a,b,c=map(int,input().split())
  lst.append([a,b,c])
C=[[float('inf')]*3]*n
C[0][0]=lst[0][0]
C[0][1]=lst[0][1]
C[0][2]=lst[0][2]
D=[0,1,2]
d=D
for i in range(1,n-1):
  for j in d:
    e=D.remove(j)
    C[i+1][j]=C[i][e[0]]+lst[i][e[0]]
    for k in range(1,len(e)):
      if C[i][e[k]]+lst[i][e[k]]>C[i+1][j]:
        C[i+1][j]=C[i][e[k]]+lst[i][e[k]]
print(max(C[n-1]))

Buggy submission (verdict: Runtime Error):
n=int(input())
lst=[]
for i in range(n):
  a,b,c=map(int,input().split())
  lst.append([a,b,c])
C=[[float('inf')]*3]*n
C[0][0]=lst[0][0]
C[0][1]=lst[0][1]
C[0][2]=lst[0][2]
d=[0,1,2]
for i in range(1,n-1):
  for j in d:
    e=d.remove(j)
    C[i+1][j]=C[i][e[0]]+lst[i][e[0]]
    for k in range(1,len(e)):
      if C[i][e[k]]+lst[i][e[k]]>C[i+1][j]:
        C[i+1][j]=C[i][e[k]]+lst[i][e[k]]
print(min(C[n-1]))

Buggy submission (verdict: Runtime Error):
n=int(input())
lst=[]
h=[1000000000000]*(n+1)
for i in range(n):
  lst.append(list(map(int,input().split())))  
for i in range(1,n+1):
  for j in range(3):
    for k in range(3):
      if j==k:
        if h[i]>h[i-1][j]+lst[i-1][k]:
          h[i]=h[i-1][j]+lst[i-1][k]
print(h[n])