Problem:


Score : 300 points

Problem Statement

Joisino is planning to open a shop in a shopping street.

Each of the five weekdays is divided into two periods, the morning and the evening. For each of those ten periods, a shop must be either open during the whole period, or closed during the whole period. Naturally, a shop must be open during at least one of those periods.

There are already N stores in the street, numbered 1 through N.

You are given information of the business hours of those shops, F_{i,j,k}. If F_{i,j,k}=1, Shop i is open during Period k on Day j (this notation is explained below); if F_{i,j,k}=0, Shop i is closed during that period. Here, the days of the week are denoted as follows. Monday: Day 1, Tuesday: Day 2, Wednesday: Day 3, Thursday: Day 4, Friday: Day 5. Also, the morning is denoted as Period 1, and the afternoon is denoted as Period 2.

Let c_i be the number of periods during which both Shop i and Joisino's shop are open. Then, the profit of Joisino's shop will be P_{1,c_1}+P_{2,c_2}+...+P_{N,c_N}.

Find the maximum possible profit of Joisino's shop when she decides whether her shop is open during each period, making sure that it is open during at least one period.

Constraints

1≤N≤100

0≤F_{i,j,k}≤1

For every integer i such that 1≤i≤N, there exists at least one pair (j,k) such that F_{i,j,k}=1.

-10^7≤P_{i,j}≤10^7

All input values are integers.

Input

Input is given from Standard Input in the following format:

N
F_{1,1,1} F_{1,1,2} ... F_{1,5,1} F_{1,5,2}
:
F_{N,1,1} F_{N,1,2} ... F_{N,5,1} F_{N,5,2}
P_{1,0} ... P_{1,10}
:
P_{N,0} ... P_{N,10}

Output

Print the maximum possible profit of Joisino's shop.

Sample Input 1

1
1 1 0 1 0 0 0 1 0 1
3 4 5 6 7 8 9 -2 -3 4 -2

Sample Output 1

8

If her shop is open only during the periods when Shop 1 is opened, the profit will be 8, which is the maximum possible profit.

Sample Input 2

2
1 1 1 1 1 0 0 0 0 0
0 0 0 0 0 1 1 1 1 1
0 -2 -2 -2 -2 -2 -1 -1 -1 -1 -1
0 -2 -2 -2 -2 -2 -1 -1 -1 -1 -1

Sample Output 2

-2

Note that a shop must be open during at least one period, and the profit may be negative.

Sample Input 3

3
1 1 1 1 1 1 0 0 1 1
0 1 0 1 1 1 1 0 1 0
1 0 1 1 0 1 0 1 0 1
-8 6 -2 -8 -8 4 8 7 -6 2 2
-9 2 0 1 7 -5 0 -2 -6 5 5
6 -6 7 -9 6 -5 8 0 -9 -7 -7

Sample Output 3

23



Sample input:
1
1 1 0 1 0 0 0 1 0 1
3 4 5 6 7 8 9 -2 -3 4 -2


Sample output:
8

Submission status: Runtime Error

Solution code:
n = int(input())
F =[list(map(int,input().split())) for i in range(n)]
P =[list(map(int,input().split())) for i in range(n)]

ans = -INF
for i in range(1,1024):
    profit = 0
    for j in range(n):
        cnt = 0
        for x in range(10):
            if (i >> x) %2 == 1 and F[j][x] == 1:
                cnt += 1
        profit += P[j][cnt]
    ans = max(ans,profit)
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np

n = int(input())
f = np.array([list(map(int, input().split())) for i in range(n)])
p = np.array([list(map(int, input().split())) for i in range(n)])

ans = -99999999

openptn=np.array([[int(s) for s in list('{0:010b}'.format(i))] for i in range(1,2**10)])

for i in range(2**10 - 1):
	subans = 0
	for j in range(n):
		count = sum(f[j]*openptn[i])
		print(f[j]*openptn[i])
		exit()
		subans +=p[j][count]
        count = 0
		
		#print(subans)
	ans = max(ans, subans)

print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np

n = int(input())
f = np.array([list(map(int, input().split())) for i in range(n)])
p = np.array([list(map(int, input().split())) for i in range(n)])

ans = -99

openptn=np.array([[int(s) for s in list('{0:010b}'.format(i))] for i in range(1,2**10)])

for i in range(2**10):
	subans = 0
	for j in range(n):
		count = sum(f[j]*openptn[i])
		subans +=p[j][count]
		#print(subans)
	ans = max(ans, subans)

print(ans)

Submission status: Runtime Error

Solution code:
# encoding:utf-8
import copy
import numpy as np
import random

n = int(input())
F = []
for i in range(n):
    f = [int(i) for i in input().split()]
    F.append(f)



P = []
for i in range(n):
    P.append([int(i) for i in input().split()])

F = np.array(F)
P = np.array(P)


def cal_val(shop_num,open_time):
    same_time = int(np.dot(F[shop_num],open_time.T))
    # print(open_time)
    return P[shop_num,same_time+1]
#
# def to2digit(i):
#     open_time = np.zeros([10])
#     for count in range(10):
#         if i%2==1:
#             open_time[count] = 1
#         i = i//2
#     return open_time



values = []

for i in range(1,2**10):
    open_time = np.zeros([10])
    for j in range(10):
        if i%2==1:
            open_time[j] = 1
        i = i//2
    value = 0
    for shop_num in range(n):
        value += cal_val(shop_num,open_time)
    values.append(value)

print(max(values))

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10000)

N = int(input())
F = [list(map(int, input().split())) for i in range(N)]
P = [list(map(int, input().split())) for i in range(N)]
INF = 10 ** 9

def dfs(s):
    if len(s) == 10:
        value = -INF
        if "1" in s:
            value = 0
            c= [0 for i in range(10)]
            for i in range(5):
                for j in range(2):
                    for k in range(N):
                        if int(s[2*i+j]) * F[k][2*i+j]:
                            c[k] += 1
            for i in range(N):
                value += P[i][c[i]]
        return value
    else:
        return max(dfs(s+"0"), dfs(s+"1"))

print(dfs(""))

Submission status: Runtime Error

Solution code:
N = int(input())
F = [list(map(int, input().split())) for i in range(N)]
P = [list(map(int, input().split())) for i in range(N)]
INF = 10 ** 9

def dfs(s):
    if len(s) == 10:
        value = -INF
        if "1" in s:
            value = 0
            c= [0 for i in range(10)]
            for i in range(5):
                for j in range(2):
                    for k in range(N):
                        if int(s[2*i+j]) * F[k][2*i+j]:
                            c[k] += 1
            for i in range(N):
                value += P[i][c[i]]
        return value
    else:
        return max(dfs(s+"0"), dfs(s+"1"))

print(dfs(""))

Submission status: Runtime Error

Solution code:
#080-C 
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
n=IL()
F=[int(input().replace(" ",""), 2) for _ in range(n)]
P=[IL() for i in range(n)]
ans=-pow(10,10)
for i in range(1,pow(2,10)):
    t=0
    for f,p in zip(F,P):
        t+=p[bin(f&i).count("1")]
    ans=max(ans,t)
print(ans)

Submission status: Runtime Error

Solution code:
#from collections import Counter
N=int(input())
"""F=list(list(map(int,input().split())) for i in range(N))
P=list(list(map(int,input().split())) for i in range(N))"""
F=[int(input().replace(' ',''),2)for _ in[0]*N]
P=[list(map(int,input().split()))for _ in[0]*N]
ans=-(1<<40)
for bit in range(1,1<<10):
    tmp = 0
    for i in range(N):
        c=0
        for j in range(10):
            if bit&(1<<j) and F[i][j]:
                c+=1
        tmp+=P[i][c]
    ans = max(ans,tmp)
print(ans)

Submission status: Runtime Error

Solution code:
MIN = -(10**7)-1

def solve():
    cnt = 0
    i = 0
    for lst in f_lst:
        chk_range = sum(lst)
        cnt += max(p_lst[i][1:chk_range])
        i += 1
    if cnt < 0:
        cnt = min(min(p_lst))
    return cnt


n = int(input())
f_lst = [[] for _ in range(n)]
p_lst = [[] for _ in range(n)]
for i in range(n):
    f_lst[i].extend(map(int,input().split()))
for i in range(n):
    p_lst[i].extend(map(int,input().split()))

ans = solve()
print(ans)

Submission status: Runtime Error

Solution code:
MIN = -(10**7)-1

def solve():
    cnt = 0
    i = 0
    for lst in f_lst:
        chk_range = sum(lst)
        cnt += max(p_lst[i][1:chk_range])
        i += 1
    if cnt < 0:
        cnt = min(min(p_lst))
    return cnt


n = int(input())
f_lst = [[] for _ in range(n)]
p_lst = [[] for _ in range(n)]
for i in range(n):
    f_lst[i].extend(map(int,input().split()))
for i in range(n):
    p_lst[i].extend(map(int,input().split()))

ans = solve()
print(f_lst)
print(p_lst)
print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
f = [list(map(int, input().split())) for _ in range(n)]
p = [list(map(int, input().split())) for _ in range(n)]
res = -10**10
for i in range(1, 1<<10):
    count = [0 for _ in range(10)]
    for j in range(10):
        for k in range(n):
            if (i>>j)&1 == 1 and f[k][j] == 1:
                count[k] += 1
    total = 0
    for k in range(n):
        total += p[k][count[k]]
    res = max(res, total)
print(res)

Submission status: Runtime Error

Solution code:
I=input;n=int(I());print(max(sum(p[bin(i&f).count('1')]for f,p in zip([int(I()[::2],2)for _ in[0]*n],[list(map(int,I().split()))for _ in[0]*n]))for i in range(1,1024)))

Submission status: Runtime Error

Solution code:
N=int(input())
C=[]
S=[]
F=[]
from math import ceil
for _ in range(N-1):
    c,s,f=map(int,input().split())
    C.append(c)
    S.append(s)
    F.append(f)
ans=[]
for i in range(0,N-1):
    t=S[i]+C[i]
    sta=i+1
    while sta<N-1:
        if t<=S[sta]:
            t=S[sta]+C[sta]
        else:
            k=ceil((t-S[sta])/F[sta])
            t=S[sta]+k*F[sta]+C[sta]
        sta+=1
    ans.append(t)
for a in ans:
    print(a)
print(0)

Submission status: Runtime Error

Solution code:
n = int(input())
f = []
p = []
for _ in range(n):
  f.append(list(map(int, input().strip().split())))
for _ in range(n):
  p.append(list(map(int, input().strip().split())))

maxt = None
for i in range(1, 2**10):
  total = 0
  for _f, _p in zip(f, p):
    c = 0
    for bi, fi in zip(bin(i)[2::-1], _f):
      if fi==1 and int(bi)==1:
        c += 1
    total += _p[c]
  maxt = max(total, maxt) if maxt is not None else total
print(maxt)

Submission status: Runtime Error

Solution code:
n = int(input())
F = [[int(i) for i in input().split()] for i in range(n)]
P = [[int(i) for i in input().split()] for i in range(n)]

def f(x):
    if x % 2 == 0:
        return 1
    else:
        return 0
    
ans = -10 ** 10
for i in range(1, 2 ** 10):
    for j in range(10):
        A[j] = f(i // (2 ** (10 - i)))

    temp = 0
    for s in range(n):
        count = 0
        for t in range(10):
            if F[s][t] == 1 and A[t] == 1:
                count += 1
        temp += P[s][count]
    ans = max(ans, temp)
        
print(ans)

Submission status: Runtime Error

Solution code:
p0 = []
maxp = []
for i in range(n):
    p0.append(p[i][0])
    sumf = sum(f[i])
    maxp.append(max(p[i][1:(sumf+1)]))

cnt = 0
sum_max = 0
for i in range(n):
    if p0[i] > maxp[i]:
        cnt += 1
    sum_max += max(p0[i],maxp[i])

if cnt == n:
    a = []
    for i in range(n):
        a.append(p0[i] + sum(maxp[:i]) + sum(maxp[i+1:]))
    print(max(a))
else:
    print(sum_max)

Submission status: Runtime Error

Solution code:
ls = []
def onoff(n):
    global ls
    if len(n) == 10:
        ls.append(n)
    else:
        onoff(n + '0')
        onoff(n + '1')
onoff('0')
onoff('1')
del ls[0]
n = int(input())
f = [list(map(str,input().split())) for x in range(n)]
p = [list(map(int,input().split())) for x in range(n)]
ans = -99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
for i in range(1024):
    check = 0
    for j in range(n):
        count = 0
        for k in range(10):
            if ls[i][k] == f[j][k] and ls[i][k] == '1':
                count += 1
        check += p[j][count]
    ans = max(ans,check)
print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
f = []
for i in range(n):
    f.append(list(map(int, input().split())))
p = []
for i in range(n):
    p.append(list(map(int, input().split())))
count = {}
ans = []
for bits in range(1 << 10):
    count = {}
    for i in range(10):
        if (bits >> i & 1) == 1:
            for j in range(n):
                if j not in count: 
                    count[j] = f[j][i]
                else:
                    count[j] += f[j][i]
    if count != {}:
        if count[0] > 0 or count[1] > 0 or count[2] > 0: 
            check = p[0][count[0]] + p[1][count[1]] + p[2][count[2]]
            ans.append(check)
print(max(ans))

Submission status: Runtime Error

Solution code:
n = int(input())
f = []
for i in range(n):
    f.append(list(map(int, input().split())))
p = []
for i in range(n):
    p.append(list(map(int, input().split())))
count = {}
ans = []
for bits in range(1 << 10):
    count = {}
    for i in range(10):
        if (bits >> i & 1) == 1:
            for j in range(n):
                if j not in count: 
                    count[j] = f[j][i]
                else:
                    count[j] += f[j][i]
    if count != {}:
        if count[0] > 0 and count[1] > 0 and count[2] > 0: 
            check = p[0][count[0]] + p[1][count[1]] + p[2][count[2]]
            ans.append(check)
print(max(ans))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun Nov  4 17:22:42 2018
ABC080
@author: maezawa
"""
import itertools as itr

n = int(input())
f = []
for i in range(n):
    f.append(list(map(int, input().split())))
p = []
for i in range(n):
    p.append(list(map(int, input().split())))
    
#print(f)
#print(p)
profit = -10**8
for oph in itr.product([0,1], repeat=10):
    if oph == (0,0,0,0,0,0,0,0,0,0):
        continue
    c = [0]*n
    for i in range(n):
        c[i] = sum([f[i][j] for j in range(10) if oph[j]==1])
    pcurrent = sum([p[i][c[i]] for i in range(n+1)])
    if pcurrent > profit:
        profit = pcurrent
        #print(oph)

print(profit)

Submission status: Runtime Error

Solution code:
from itertools import product
al=list(product([0,1],repeat=10))
n=int(input())
a=[list(map(int, input().split())) for i in range(n)]
p=[list(map(int, input().split())) for i in range(n)]
ans-100000000000
for i in al:
    if sum(i)==0:continue
    q=0
    for j in range(n):
        count=0
        for k in range(10):
            if a[j][k]==1 and i[k]==1:
                count+=1
        q+=p[j][count]
    ans=max(ans,q)
print(ans)

Submission status: Runtime Error

Solution code:
import math
N = int(input())
F = [[] * 10 for i in range(N)]
for i in range(N):
    F[i] = list(map(int, input().split()))
P = [[] * 11 for i in range(N)]
for i in range(N):
    P[i] = list(map(int, input().split()))
L = [0] * 10
Sum_max = -float(math.inf)
for i in range(1, 1024):
    for j in range(10):
        L[j] = i % 2
        i = int(i / 2)
    Sum = 0
    for j in range(N):
        count = 0
        for k in range(10):
            if L[k] == 1 and F[j][k] == 1:
                count += 1
        Sum += P[j][count]
    Sum_max = max(Sum_max, Sum)
print(Sum_max)

Submission status: Runtime Error

Solution code:
#-*-coding:utf-8-*-

def main():
    n = int(input())
    f_list = []
    p_list = []
    #f_list = [list(map(int, input().split())) for i in range(n)]
    #p_list = [list(map(int, input().split())) for i in range(n)]

    for i in range(N):
        tmp=list(map(int, input().split()))
        f_list.append(tmp)
 
    for i in range(N):
        tmp=list(map(int, input().split()))
        p_list.append(tmp)

    max_profit = -10000000

    for i in range(1, 2 ** 10):
        binary = [0] * 10
        now = i 
        for j in range(10):
            binary[j] = now % 2
            now = now // 2
        profit = 0
        for j in range(n):
            one_cnt = 0
            for h in range(10):
                if f_list[j][h] * binary[h] == 1:
                    one_cnt += 1
            profit += p_list[j][one_cnt]
        if max_profit < profit:
            max_profit = profit
    print(max_profit)
    
    
if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import math
import numpy as np
N = int(input())
F = [[int(x) for x in input().split()] for _ in range(N)]
P = [[int(x) for x in input().split()] for _ in range(N)]

f = np.array(F)
ans = -math.inf
for n in range(1, 2**10):
    a = np.array([int(x) for x in bin(n)[2:].rjust(10, '0')])
    p = sum([P[i][x] for i,x in enumerate(np.sum(f * a, axis=1))])
    ans = max(ans, p)
print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
ans = float("-INF")
f = [[0 for i in range(10)] for i in range(n)]
p = [[0 for i in range(10)] for i in range(n)]
for i in range(n):
  ft = list(map(int, input().split()))
  for j in range(10):
    f[i][j] = ft[j]
for i in range(n):
  pt = list(map(int, input().split()))
  for j in range(10):
    p[i][j] = pt[j]

for i in range(1, 2**10):
  t = 0
  for j in range(n):
    c = 0
    for k in range(10):
      if i>>k&1 and f[j][k]:
        c += 1
    t += p[j][c]
  ans = max(ans, t)
print(ans)

Submission status: Runtime Error

Solution code:
def ans():
    tmp = -9999999999999
    N = int(input())
    F = [list(map(int, input().split())) for i in range(N)]
    P = [list(map(int, input().split())) for i in range(N)]

    def calculate(B):
        v = []
        for n in range(N):
            mcnt = 0
            for k in range(10):
                if B[k] == '1' and F[n][k] == 1:
                    mcnt += 1
            v.append(P[n][mcnt])
        return sum(v)

    for i in range(1, 1 << 10):
        bi = bin(i)
        bi = bi[2:]
        bi = '0' * (10 - len(bi)) + bi
        tmp = max(tmp, calculate(bi))
    return print(tmp)
  
  ans()

Submission status: Runtime Error

Solution code:
n = int(input())
f = [list(map(int,input().split())) for _ in range(n)]
p = [list(map(int,input().split())) for _ in range(n)]

a     = []
count = 0
point = []
PP = []

for _ in range(1025,2048):
    a.append(list(map(int,list(bin(_)[3:]))))

for k in range(1024):
    for i in range(n):
        for j in range(10):
            if f[i][j]&a[k][j] == 1:
                count += 1
        point.append(p[i][count])
        count = 0
    PP.append(sum(point))
    point = []
print (max(PP))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

import sys

n = int(raw_input().split()[0])
tl = []
for i in range(n):
    e = [int(e) for e in raw_input().split()]
    tl.append(e)
#print tl

t = 0
x = 0
y = 0
ans = 'Yes'
for i in tl:
    ti, xi, yi = i
    dt = ti - t
    dx = abs(xi - x)
    dy = abs(yi - y)
    # print [t,x,y], i, [dt,dx,dy],
    if (dx + dy) > dt:
        # print '!',
        ans = 'No'
        break
    if (dt - (dx + dy)) & 1:
        # print '!!',
        ans = 'No'
        break
    # print
    t = ti
    x = xi
    y = yi
    
# print
sys.stdout.write('%s\n' % (ans))
sys.stdout.flush()

Submission status: Runtime Error

Solution code:
import itertools
n = int(input())
f = []
for i in range(n):
    f.append(list(map(int, input().split())))
p = []
for i in range(n):
    p.append(list(map(int, input().split())))

a = [i for i in range(10)]
combi = []
for i in range(10):
    combi.extend(list(itertools.combinations(a,i+ 1)))
#print(combi)

ans =  - float("inf")
for i in combi:
    #print(i)
    cnt = [0]*10
    for j in i:
        for k in range(n):
            cnt[k] += f[k][j]
    profit = sum([p[k][cnt[k]] for k in range(n)])
    ans = max(ans, profit)
print(ans)

Submission status: Runtime Error

Solution code:
# -*- Coding: utf-8 -*-
n_shop = int(input())
i_schedule = []
i_benefit = []

max_profit = 0

#開店スケジュールを2進数→10進数に変換
for i in range(n_shop):
    i_schedule.append(int(input().replace(" ",""),2))
    
for i in range(n_shop):
    i_benefit.append(list(map(int,input().split())))
    max_profit += min(i_benefit[i])
    
#全パターンの開店スケジューるの作成
#一つ以上の時間帯で店は開店しなければならない

#schedule=[format(i, '010b') for i in range(1,1024)]
schedule = [i for  i in range(1,1024)]

#そこから一致数の計算→リストのcountメソッドを使う
for sch in schedule:
    anded = []
    for j in range(n_shop):
        anded.append(format(sch & i_schedule[j], "b").count("1"))     #一致スケジュールを2進数表記にして，1の数を計算
        
    profit = sum_benefit(anded)
    
    if max_profit <= profit:
        max_profit = profit
    
        
    

#最後に一致数から利益の計算
def sum_benefit(anded):
    summed= 0
    for shop in range(n_shop):
        sum += i_benefit[shop][anded[shop]]
    return summed

print(max_profit)

Submission status: Runtime Error

Solution code:
N = int(input())

F = [int(input().replace(" ",""),2) for _ in range(N)]
P = [list(map(int, input().split())) for _ in range(N)]


profit = float("-inf")

for i in range(1,1024):
	tmp = 0
	for j in range(N):
		tmp = tmp + (bin(i & F[j]).count('1'))
		tmp2 = P[j][tmp]
	profit = max(profit, tmp2)

print(profit)

Submission status: Runtime Error

Solution code:
N = int(input())

F = [int(input().replace(" ",""),2) for _ in range(N)]
P = [list(map(int, input().split())) for _ in range(N)]


profit = float("-inf")

for i in range(1,1024):
	tmp = 0
	for j in range(N):
		if i & F[j] :
			tmp = tmp + 1
			tmp2 = P[tmp]
	profit = max(profit, tmp2)

print(profit)

Submission status: Runtime Error

Solution code:
    n = int(input())
     
    f = [int(input().replace(" ", ""), 2) for _ in range(n)]
    p = [list(map(int, input().split())) for _ in range(n)]
     
    ans = float('-inf')
     
    for i in range(1, 1024):
        price = 0
        for j in range(n):
            price += p[j][bin(i & f[j]).count('1')]
        ans = max(ans, price)
     
    print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
shop_i = []
for i in range(n):
    shop_i.append(list(map(int, input().split())))
gain_i = []
for i in range(n):
    gain_i.append(list(map(int, input().split())))

gain_max = -100000000
for i in range(2**10):
    if i ==0:
        pass
    else:        
        shop_sister = format(i, '010b')
        gain_now = []
        times = 0
        for shop in range(n):
            for n_cap in range(10):
                if shop_i[shop][n_cap] == 1 and shop_sister[n_cap] == '1':
                    times += 1
            gain_now.append(gain_i[shop][times]) 
        gain_now = sum(gain_now)
        if gain_now>gain_max:
            gain_max = gain_now

print(gain_max)

Submission status: Runtime Error

Solution code:
# coding:utf-8
inp = input()
N = int(inp)

eigyo = []

b = []
Ci = []
for i in range(N):
    N_ = list(map(int, input().split()))
    eigyo.append(N_)
    Ci.append(sum(N_))

P = []
for i in range(N):
    P.append(list(map(int, input().split())))


ans = 0
a = list(map(lambda x: x*0, list(range(10))))
count = 0

def func():
    #score = 0
    global count
    count += 1
    #print(count, a)
    cc = 0
    for i in range(N):
        count_c = 0
        for j,element in enumerate(eigyo[N]):
            if element==a[j]:
                count_c += 1
        cc += P[i][count_c]

    global ans
    ans = max(ans, cc)
            
    #ans = max(ans, score)

def dfs(pos):
    if pos==10:
        func()
        return
    a[pos] = 0
    dfs(pos+1)
    a[pos] = 1
    dfs(pos+1)


dfs(0)
print(ans)

Submission status: Runtime Error

Solution code:
# coding :utf-8
N=int(input())

F=[]
P=[]

table = [2**i for i in range(10)]
#print(table)

for i in range(N):
    lis = list(map(int, input().split()))
    F.append(lis)
#print(F)
for i in range(N):
    lis = list(map(int, input().split()))
    P.append(lis)
#print(P)

max=-1000000000001

for i in range(1,1024):
    total=0
    for j in range(N):
        n=0
        for k in range(10):
            n +=(1 if i&table[k] !=0 else 0)*F[j][t]
        total += P[j][n]
    if total >maxx:
        maxx= total
print(maxx)

Submission status: Runtime Error

Solution code:
import sys
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
INF = float("inf")
sys.setrecursionlimit(10**7)

# 4近傍（右, 下, 左, 上）
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]


def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W


def main():
    N = int(input())
    F = [[0] * 10 for _ in range(N)]
    for i in range(N):
        s = input().split()
        for j in range(10):
            F[i][j] = int(s[j])
    P = [[0] * 10 for _ in range(N)]
    for i in range(N):
        s = input().split()
        for j in range(10):
            P[i][j] = int(s[j])

    ans = -INF
    # 2 ^ nの組み合わせの全列挙
    for b in range(1, 2 ** 10):
        o = [0] * 10
        for i in range(10):
            if b & 1 << i:
                o[i] = 1

        total = 0
        for i in range(N):
            c = 0
            for j in range(10):
                if o[j] == 1 and F[i][j] == 1:
                    c += 1
            total += P[i][c]
        ans = max(ans, total)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
# coding: utf-8

N = int(input())

F = []
P = []


table = [2**i for i in range(10)]

for i in range(N):
    lis = list(map(int, input().split()))
    F.append(lis)

for i in range(N):
    lis = list(map(int, input().split()))
    P.append(lis)

maxx = -1000000001

for i in range(1, 1025):
    total = 0
    for j in range(N):
        n = 0
        for t in range(10):
            n += (i&table[t])*F[j][t]
        total += P[j][n]
    if total > maxx:
        maxx = total

print(maxx)

Submission status: Runtime Error

Solution code:
n=int(input())

ans=-10**9
f=[[0 for i in range(10)] for j in range(n)]
p=[[0 for i in range(11)] for j in range(n)]

for i in range(n):
  f[i]=[int(i) for i in input().split()]
for i in range(n):
  p[i]=[int(i) for i in input().split()]


for i1 in range(2):
  for i2 in range(2):
    for i3 in range(2):
      for i4 in range(2):
        for i5 in range(2):
          for i6 in range(2):
            for i7 in range(2):
              for i8 in range(2):
                for i9 in range(2):
                  for i10 in range(2):
                    sumi=i1+i2+i3+i4+i5+i6+i7+i8+i9+i10
                    count=[0 for i in range(11)]
                    for ii in range(n):
                        if i1==f[ii][0] and i1==1:
                          count[ii]=count[ii]+1
                        if i2==f[ii][1] and i2==1:
                          count[ii]=count[ii]+1
                        if i3==f[ii][2] and i3==1:
                          count[ii]=count[ii]+1
                        if i4==f[ii][3] and i4==1:
                          count[ii]=count[ii]+1   
                        if i5==f[ii][4] and i5==1:
                          count[ii]=count[ii]+1
                        if i6==f[ii][5] and i6==1:
                          count[ii]=count[ii]+1
                        if i7==f[ii][6] and i7==1:
                          count[ii]=count[ii]+1
                        if i8==f[ii][7] and i8==1:
                          count[ii]=count[ii]+1
                        if i9==f[ii][8] and i9==1:
                          count[ii]=count[ii]+1   
                        if i10==f[ii][9] and i10==1:
                          count[ii]=count[ii]+1                          
                    
                    if sumi>0:
                      ans_0=0
                      #print(count)
                      for i in range(n):
                         ans_0=ans_0+p[i][count[i]]
                      ans=max(ans,ans_0)
                          
                                                                            
print(ans)

Submission status: Runtime Error

Solution code:
n=int(input())

ans=-10**9
f=[[0 for i in range(10)] for j in range(n)]
p=[[0 for i in range(11)] for j in range(n)]

for i in range(n):
  f[i]=[int(i) for i in input().split()]
for i in range(n):
  p[i]=[int(i) for i in input().split()]


for i1 in range(2):
  for i2 in range(2):
    for i3 in range(2):
      for i4 in range(2):
        for i5 in range(2):
          for i6 in range(2):
            for i7 in range(2):
              for i8 in range(2):
                for i9 in range(2):
                  for i10 in range(2):
                    sumi=i1+i2+i3+i4+i5+i6+i7+i8+i9+i10
                    count=[0 for i in range(10)]
                    for ii in range(n):
                        if i1==f[ii][0] and i1==1:
                          count[ii]=count[ii]+1
                        if i2==f[ii][1] and i2==1:
                          count[ii]=count[ii]+1
                        if i3==f[ii][2] and i3==1:
                          count[ii]=count[ii]+1
                        if i4==f[ii][3] and i4==1:
                          count[ii]=count[ii]+1   
                        if i5==f[ii][4] and i5==1:
                          count[ii]=count[ii]+1
                        if i6==f[ii][5] and i6==1:
                          count[ii]=count[ii]+1
                        if i7==f[ii][6] and i7==1:
                          count[ii]=count[ii]+1
                        if i8==f[ii][7] and i8==1:
                          count[ii]=count[ii]+1
                        if i9==f[ii][8] and i9==1:
                          count[ii]=count[ii]+1   
                        if i10==f[ii][9] and i10==1:
                          count[ii]=count[ii]+1                          
                    
                    if sumi>0:
                      ans_0=0
                      #print(count)
                      for i in range(n):
                         ans_0=ans_0+p[i][count[i]]
                      ans=max(ans,ans_0)
                          
                                                                            
print(ans)

Submission status: Runtime Error

Solution code:
n=int(input())

ans=-10**9
f=[[0 for i in range(10)] for j in range(n)]
p=[[0 for i in range(10)] for j in range(n)]

for i in range(n):
  f[i]=[int(i) for i in input().split()]
for i in range(n):
  p[i]=[int(i) for i in input().split()]



for i1 in range(2):
  for i2 in range(2):
    for i3 in range(2):
      for i4 in range(2):
        for i5 in range(2):
          for i6 in range(2):
            for i7 in range(2):
              for i8 in range(2):
                for i9 in range(2):
                  for i10 in range(2):
                    sumi=i1+i2+i3+i4+i5+i6+i7+i8+i9+i10
                    count=[0 for i in range(10)]
                    for ii in range(n):
                        if i1==f[ii][0] and i1==1:
                          count[ii]=count[ii]+1
                        if i2==f[ii][1] and i2==1:
                          count[ii]=count[ii]+1
                        if i3==f[ii][2] and i3==1:
                          count[ii]=count[ii]+1
                        if i4==f[ii][3] and i4==1:
                          count[ii]=count[ii]+1   
                        if i5==f[ii][4] and i5==1:
                          count[ii]=count[ii]+1
                        if i6==f[ii][5] and i6==1:
                          count[ii]=count[ii]+1
                        if i7==f[ii][6] and i7==1:
                          count[ii]=count[ii]+1
                        if i8==f[ii][7] and i8==1:
                          count[ii]=count[ii]+1
                        if i9==f[ii][8] and i9==1:
                          count[ii]=count[ii]+1   
                        if i10==f[ii][9] and i10==1:
                          count[ii]=count[ii]+1                          
                    
                    if sumi>0:
                      ans_0=0
                      #print(count)
                      for i in range(n):
                        if count[i]!=0:
                          ans_0=ans_0+p[i][count[i]]
                        
                      ans=max(ans,ans_0)
                          
                                                                            
print(ans)