Problem p03503 (python)

Fixed submission:
n=int(input())
F=[[] for i in range(10)]
for i in range(n):
    for j,f in enumerate(list(map(int,input().split()))):
        if f:
            F[j].append(i)
P=[list(map(int,input().split())) for i in range(n)]
ans=-float("inf")
for i in range(1,1024):
    l=[0]*n
    for j in range(10):
        if i>>j&1:
            for k in F[j]:
                l[k]+=1
    t=0
    for j,k in enumerate(l):
        t+=P[j][k]
    ans=max(ans,t)
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
N = int(input())

time_lis = [0] * N
profit = [0] * N
for n in range(N):
    time_lis[n] = list(map(int, input().split()))
for n in range(N):
    profit[n] = list(map(int, input().split()))

ans = 0
always_zero = True
for n in range(N):
    count_1 = len([i for i in time_lis[n] if i == 1])
    tmp= max(profit[n][:count_1 + 1])
    ans += tmp
    if profit[n].index(tmp) != 0:
        always_zero = False
if always_zero:
    max_prof = sorted([(item[0], item[1]) for item in profit], key=lambda x: -x[1])
    print(ans - max_prof[0] + max_prof[1])
    sys.exit()
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
N = int(input())

time_lis = [0] * N
profit = [0] * N
for n in range(N):
    time_lis[n] = list(map(int, input().split()))
for n in range(N):
    profit[n] = list(map(int, input().split()))

ans = 0
always_zero = True
for n in range(N):
    count_1 = len([i for i in time_lis[n] if i == 1])
    ans += max(profit[n][:count_1 + 1])
    if profit[n].index(ans) != 0:
        always_zero = False
if always_zero: 
    max_prof = sorted([(item[0], item[1]) for item in profit], key=lambda x: -x[1])
    print(ans - max_prof[0][0] + max_prof[0][1])
    sys.exit()
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
N = int(input())

time_lis = [0] * N
profit = [0] * N
for n in range(N):
    time_lis[n] = list(map(int, input().split()))
for n in range(N):
    profit[n] = list(map(int, input().split()))

ans = 0
always_zero = True
for n in range(N):
    count_1 = len([i for i in time_lis[n] if i == 1])
    ans += max(profit[n][:count_1 + 1])
    if profit[n].index(ans) != 0:
        always_zero = False
if always_zero: 
    max_prof = sorted([item[0], item[1] for item in profit], key=lambda x: -x[1])
    print(ans - max_prof[0][0] + max_prof[0][1])
    sys.exit()
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
N = int(input())

time_lis = [0] * N
profit = [0] * N
for n in range(N):
    time_lis[n] = list(map(int, input().split()))
for n in range(N):
    profit[n] = list(map(int, input().split()))

ans = 0
always_zero = True
for n in range(N):
    count_1 = len([i for i in time_lis[n] if i == 1])
    tmp= max(profit[n][:count_1 + 1])
    ans += tmp
    if profit[n].index(tmp) != 0:
        always_zero = False
if always_zero:
    max_prof = sorted([item[0], item[1] for item in profit], key=lambda x: -x[1])
    print(ans - max_prof[0] + max_prof[1])
    sys.exit()
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
N = int(input())

time_lis = [0] * N
profit = [0] * N
for n in range(N):
    time_lis[n] = list(map(int, input().split()))
for n in range(N):
    profit[n] = list(map(int, input().split()))

ans = 0
always_zero = True
for n in range(N):
    count_1 = len([i for i in time_lis[n] if i == 1])
    ans += max(profit[n][:count_1 + 1])
    if profit[n].index(ans) != 0:
        always_zero = False
if always_zero:
    max_prof = [item[1] for item in profit]
    print(max(max_prof))
    sys.exit()
print(ans)