Problem p02619 (python)

Fixed submission:
# -*- coding: utf-8 -*-

D = int(input())
c = list(map(int, input().split()))
s = []
t = []

for i in range(D):
    s.append(list(map(int, input().split())))

for i in range(D):
    t.append(int(input()) - 1)

last = [0] * 26

ans = 0

for i in range(D):
    ans = ans + s[i][t[i]]
    for j in range(26):
        if t[i] != j:
            last[j] += 1
            ans = ans - (c[j] * last[j])
        elif t[i] == j:
            last[j] = 0
    print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

D = int(input())
c = list(map(int, input().split()))
s1 = list(map(int, input().split()))
s2 = list(map(int, input().split()))
s3 = list(map(int, input().split()))
s4 = list(map(int, input().split()))
s5 = list(map(int, input().split()))
t1 = int(input())
t2 = int(input())
t3 = int(input())
t4 = int(input())
t5 = int(input())

t = [0] * 26

ans = 0

# 1日目
ans = ans + s1[t1 - 1]
for i in range(26):
    if (t1 - 1) != i:
        t[i] = t[i] + 1
        ans = ans - (c[i] * t[i])
    elif (t1 - 1) == i:
        t[i] = 0
print(ans)

# 2日目
ans = ans + s2[t2 - 1]
for i in range(26):
    if (t2 - 1) != i:
        t[i] = t[i] + 1
        ans = ans - (c[i] * t[i])
    elif (t2 - 1) == i:
        t[i] = 0
print(ans)

# 3日目
ans = ans + s3[t3 - 1]
for i in range(26):
    if (t3 - 1) != i:
        t[i] = t[i] + 1
        ans = ans - (c[i] * t[i])
    elif (t3 - 1) == i:
        t[i] = 0
print(ans)

# 4日目
ans = ans + s4[t4 - 1]
for i in range(26):
    if (t4 - 1) != i:
        t[i] = t[i] + 1
        ans = ans - (c[i] * t[i])
    elif (t4 - 1) == i:
        t[i] = 0
print(ans)

# 5日目
ans = ans + s5[t5 - 1]
for i in range(26):
    if (t5 - 1) != i:
        t[i] = t[i] + 1
        ans = ans - (c[i] * t[i])
    elif (t5 - 1) == i:
        t[i] = 0
print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

D = int(input())
c = list(map(int, input().split()))
s1 = list(map(int, input().split()))
s2 = list(map(int, input().split()))
s3 = list(map(int, input().split()))
s4 = list(map(int, input().split()))
s5 = list(map(int, input().split()))
t1 = int(input())
t2 = int(input())
t3 = int(input())
t4 = int(input())
t5 = int(input())

t = [0] * 26

ans = 0

# 1日目
# 満足度加算
ans = ans + s1[t1 - 1]
# 満足度減算
for i in range(26):
    if (t1 - 1) != i:
        t[i] = t[i] + 1
        ans = ans - (c[i] * t[i])
    elif (t1 - 1) == i:
        t[i] = 0
print(ans)

# 2日目
# 満足度加算
ans = ans + s2[t2 - 1]
# 満足度減算
for i in range(26):
    if (t2 - 1) != i:
        t[i] = t[i] + 1
        ans = ans - (c[i] * t[i])
    elif (t2 - 1) == i:
        t[i] = 0
print(ans)

# 3日目
# 満足度加算
ans = ans + s3[t3 - 1]
# 満足度減算
for i in range(26):
    if (t3 - 1) != i:
        t[i] = t[i] + 1
        ans = ans - (c[i] * t[i])
    elif (t3 - 1) == i:
        t[i] = 0
print(ans)

# 4日目
# 満足度加算
ans = ans + s4[t4 - 1]
# 満足度減算
for i in range(26):
    if (t4 - 1) != i:
        t[i] = t[i] + 1
        ans = ans - (c[i] * t[i])
    elif (t4 - 1) == i:
        t[i] = 0
print(ans)

# 5日目
# 満足度加算
ans = ans + s5[t5 - 1]
# 満足度減算
for i in range(26):
    if (t5 - 1) != i:
        t[i] = t[i] + 1
        ans = ans - (c[i] * t[i])
    elif (t5 - 1) == i:
        t[i] = 0
print(ans)