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: Accepted

Solution code:
from itertools import product
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 = -10**18
for p in product([0, 1], repeat = 10):
    if sum(p) == 0:
        continue
    res = 0
    for i in range(N):
        cnt = 0
        for j in range(10):
            if p[j]:
                cnt += F[i][j]
        res += P[i][cnt]
    ans = max(ans, res)
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
F=[[0 for i in range(10)]for i in range(N)]
for i in range(N):
    st=input().split()
    indexnum=0
    for j in range(10):
            tmp=True
            if int(st[indexnum]):
                tmp=True
            else:
                tmp=False
            F[i][j]=tmp
            indexnum+=1
P=[[0 for i in range(11)] for i in range(N)]
for i in range(N):
    st=input().split()
    for j in range(10):
        P[i][j]=int(st[j])
xmax=-1e+10
for t in range(1,1024):
    a=[0 for i in range(10)]
    s=t
    for i in range(10):
       a[i]=(s%2)
       s=(s-a[i])//2
    x=0
    for i in range(N):
        c=0
        for j in range(10):
            if F[i][j] and a[j]==1:
                c+=1
        x+=P[i][c]
    if xmax<x:
        xmax=x
print(xmax)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import numpy as np
import itertools
n = int(input())
f = np.zeros((n,10),dtype='int32')
p = np.zeros((n,11),dtype='int32')
for i in range(n):
    f[i] = list(map(int,input().split()))
for i in range(n):
    p[i] = list(map(int,input().split()))
    

op = [0,1]
ans = -10**9
pro = list(itertools.product(op, repeat=10))
for i in pro:
    if(sum(i)==0):continue
    tmp = 0
    for j in range(n):
        tmp += p[j][np.dot(np.array(i),f[j])]
    ans = max(ans,tmp)
print(ans)

Submission status: Accepted

Solution code:
N=int(raw_input())

f=[]
for _ in range(N):
  f.append(map(int,raw_input().split(' ')))

p=[]
for _ in range(N):
  p.append(map(int,raw_input().split(' ')))

s=float('-inf')
for t in range(1,1024):
  l=map(int,list(bin(t)[2:].zfill(10)))
  tmp=0
  for i in range(N):
    c=0
    for t in range(10):
      if l[t]==0:
        continue
      if f[i][t]:
        c+=1

    tmp+=p[i][c]

  if tmp>s:
    s=tmp
    
print s

Submission status: Accepted

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)]

reward_list=[]
for i in range(1023):
    k=i+1
    t=[]
    c=[0 for j in range(N)]
    while(1):
        t.append(k%2)
        k=k//2
        if(k==0):
            length=len(t)
            if(length<10):
                for i in range(10-length):
                    t.append(0)
            break
    reward=0
    for j in range(N):
        for f in range(10):
            c[j]+=F[j][f]*t[f]
        reward+=P[j][c[j]]
    reward_list.append(reward)
print(max(reward_list))

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

def solve():
    n = int(input())
    fl = [[int(i) for i in input().split()] for _ in range(n)]
    pl = [[int(i) for i in input().split()] for _ in range(n)]
    ans = -1 * 100 * (10 ** 7)
    for cnt in range(1, 2 ** 10 + 1):
        cnt_list = [0]*n
        for i in range(n):
            t = cnt
            digit = 0
            while t > 0:
                if t & 1 != 0 and fl[i][digit - 1] == 1:
                  cnt_list[i] += 1
                t >>= 1
                digit += 1
        tsum = 0
        for i in range(n):
            tsum += pl[i][cnt_list[i]]
        ans = max(tsum, ans)
    print(ans)


if __name__=="__main__":
    solve()

Submission status: Accepted

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

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


def help(a):
    if sum(a) == 0:
        return -float("inf")
    res = 0
    for i in range(n):
        num = 0
        for j in range(10):
            if a[j] == 1 and f[i][j] == 1:
                num += 1
        res += p[i][num]
    return res
lst = []
for a1 in range(2):
        for a2 in range(2):
            for a3 in range(2):
                for a4 in range(2):
                    for a5 in range(2):
                        for a6 in range(2):
                            for a7 in range(2):
                                for a8 in range(2):
                                    for a9 in range(2):
                                        for a10 in range(2):
                                            res = help([a1, a2, a3, a4, a5, a6, a7, a8, a9, a10])
                                            lst.append(res)
print(max(lst))

Submission status: Accepted

Solution code:
N = int(input())

F = []
for _ in range(N):
    f = []
    for i in input().split():
        f.append(1 if i == '1' else 0)
    F.append(f)

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

ans = -1000000000
for i in range(1, 1024):
    val = 0
    S = []
    for j in range(10):
        S.append(1 if i & 2 ** j else 0)
    for k in range(N):
        n = 0
        for l in range(10):
            n += S[l] * F[k][l]
        val += P[k][n]
    if val > ans:
        ans = val

print(ans)

Submission status: Accepted

Solution code:
import itertools

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

best = -100000000000
for i in range(1, 11):
    for x in itertools.combinations(range(0, 10), i):
        sum = 0
        for j in range(n):
            fs = 0
            for k in x:
                if f[j][k] == 1: fs += 1
            sum += p[j][fs]
        if sum > best:
            best = sum
print best

Submission status: Accepted

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)]

ans = -1e10
for i in range(1, 2**10):
    d = [0 for _ in range(n)]
    pi = 0
    for j in range(10):
        if (1 << j) & i:
            for k in range(n):
                d[k] += f[k][j]
    ans = max(ans, sum(map(lambda k: p[k][d[k]], range(n))))

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
isopen = [list(map(int,input().split())) for i in range(N)]
gain = [list(map(int,input().split())) for i in range(N)]

ans = -float('inf')
for i in range(1,2**10):
    tmp = 0
    for n in range(N):
        c = 0
        for b in range(10):
            if ((i >> b)&1) & isopen[n][b]:
                c += 1
        tmp += gain[n][c]
    ans = max(ans, tmp)
print(ans)

Submission status: Accepted

Solution code:
import sys
import itertools

def get_ben(time_list, shop_open_list, ben_list):
    count_list = []
    for shop_list in shop_open_list:
        count_list.append(len(list(filter(lambda i: (shop_list[i] == 1) and (time_list[i] == 1), list(range(10))))))
    res = 0
    for i, count in enumerate(count_list):
        res += ben_list[i][count]
    return res

n = int(sys.stdin.readline().strip())

shop_open_list = []
ben_list =[]

for _ in range(n):
    shop_open_list.append(list(map(int, sys.stdin.readline().strip().split(" "))))

for _ in range(n):
    ben_list.append(list(map(int, sys.stdin.readline().strip().split(" "))))

B = (0,1)
cand = []
for l in itertools.product(B, repeat = 10):
    if sum(l) == 0:
        continue
    cand.append(get_ben(l, shop_open_list, ben_list))

print(str(max(cand)))

Submission status: Accepted

Solution code:
if __name__ == '__main__':

    n = int(input())
    fs = []
    for i in range(n):
        vs = list(map(int, input().split()))
        fs.append(vs)
    ps = []
    for i in range(n):
        vs = list(map(int, input().split()))
        ps.append(vs)

    from itertools import product

    ans = -10 ** 10
    for decision in product([0, 1], repeat=10):
        if not any(decision):
            continue
        tans = 0
        for fv, pv in zip(fs, ps):
            c = 0
            for f, d in zip(fv, decision):
                c += f * d
            tans += pv[c]
        ans = max(ans, tans)
    print(ans)

Submission status: Accepted

Solution code:
N = input()
F = [map(int, raw_input().split()) for _ in range(N)]
P = [map(int, raw_input().split()) for _ in range(N)]
ans = -10**100
for b in range(1,2**10):
  a = 0
  for i in range(N):
    c = 0
    for j in range(10):
      c += int(b>>j&1 and F[i][j])
    a += P[i][c]
  ans = max(ans, a)
print ans

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n = ni()
fs = []
for i in range(n):
    x = na()
    ptn = 0
    for j in range(10):
        ptn |= x[j]<<j
    fs.append(ptn)
ps = []
for i in range(n):
    ps.append(na())

def bct(x):
    ret = 0
    while x > 0:
        ret += x&1
        x >>=1
    return ret

ans = -9999999999999999
for i in range(1, 1024):
    s = 0
    for j in range(n):
        s += ps[j][bct(fs[j]&i)]
    ans = max(ans, s)
print(ans)

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 = -10**9
for i in range(2**10-1):
  Bit = [1]**10
  for j in range(10):
    if (i>>j)&1:
      Bit[j]=0
  count = 0
  for k in range(N):
    op = sum(b&f for b,f in zip(Bit,F[k]))
    count+=P[k][op]
  ans = max(ans,count)
 
print(ans)

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 = -10**9
for i in range(2**10-1):
  Bit = [0]**10
  for j in range(10):
    if (i>>j)&1:
      Bit[j]=1
  count = 0
  for k in range(N):
    op = sum(b&f for b,f in zip(Bit,F[k]))
    count+=P[k][op]
  ans = max(ans,count)

print(ans)

Submission status: Runtime Error

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

maxi = -10**10

for i in range(1,2 ** 10):
    num = [0]*10
    for j in range(10):
        if ((i >> j) & 1):
            for k in range(n):
                num[k] += l[k][j]
    benefit = 0
    for m in range(n):
        benefit += p[m][num[m]]
    maxi = max(maxi,benefit)
print(maxi)

Submission status: Runtime Error

Solution code:
N = int(input())
F = [[] for TF in range(0,N)]
for TF in range(0,N):
    F[TF] = [int(T) for T in input().split()]
P = [[] for TP in range(0,N)]
for TP in range(0,N):
    P[TP] = [int(T) for T in input().split()]
    
MAXB = -10**9
for TB in range(1,2**10):
    BaseConv,BaseSInd = ForBaseConvert(TB,10,2)
    Benefit = 0
    for TN in range(0,N):        
        Count = sum(1 if F[TN][TT]==1 else 0 for TT in BaseSInd[1])
        Benefit += P[TN][Count]
    if MAXB<Benefit:
        MAXB = Benefit
print(MAXB)

Submission status: Runtime Error

Solution code:
n = int(input())

F = []
P = []
for i in range(n):
    F.append(list(map(int, input().split())))
for i in range(n):
    P.append(list(map(int, input().split())))
ans = -10**9
for i in range(1, 1 << (10)):
    C = [0]*11
    for j in range(10):
        if i & 2**j:
            for k in range(n):
                if F[k][j]:
                    C[k] += 1
    current = 0
    for k in range(n):
        current += P[k][C[k]]
    ans = max(current, ans)
print (ans)

Submission status: Runtime Error

Solution code:
import sys
n = int(input())
F = [list(map(int, sys.stdin.readline().split())) for _ in range(n)]
P = [list(map(int, sys.stdin.readline().split())) for _ in range(n)]
ans = 0
for i in range(1,pow(2,10)):
    b = bin(i)[2:].zfill(10)
    t = 0
    for j in range(n):
        c = 0
        for k in range(10):
            if int(b[k]) and F[j][k]:
                c += 1
        a += P[j][c]
    ans = max(ans, a)
print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
data1 = [list(map(int,input().split())) for _ in range(n)]
data2 = [list(map(int,input().split())) for _ in range(n)]
ans = []
trans = -1
for i in range(2**10):
    S = [0]*10
    l = 0
    for j in range(10):
        for k in range(n):
            S[k] += data1[k][j]*((i>>j)&1)
    for j in range(n):
        l += data2[j][S[j]]
    ans.append(l)
    if not i:
        trans = l
ans.sort()
print(ans[-1] if ans[-1] != trans else ans[-2])

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 j in range(n)] 

ans = -9999999999

for i in range(1, 1024): 
    bf = 0  
    for j in range(n):  
        cnt = 0 
        for k in range(10): 
            if (i >> k) & 1 == 1 and f[j][k] == 1: 
                cnt += 1 
        bf += p[j][cnt] 
    ans =max(ans, bf)  　
    
print(ans)

Submission status: Runtime Error

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

ci = 0
c = []
P_max = -1000000000
for i in range(2):
    for j in range(2):
        for k in range(2):
            for l in range(2):
                for m in range(2):
                    for n in range(2):
                        for o in range(2):
                            for p in range(2):
                                for q in range(2):
                                    for r in range(2):
                                        if i==j==k==l==m==n==o==p==q==r==0:
                                            pass
                                        for s in range(N):
                                            ci = F[s][0]*i + F[s][1]*j + F[s][2]*k + F[s][3]*l + F[s][4]*m + F[s][5]*n + F[s][6]*o + F[s][7]*p + F[s][8]*q + F[s][9]*r
                                            c.append(ci)
                                        P_sample = P[0][c[0]] + P[1][c[1]] + P[2][c[2]] + P[3][c[3]] + P[4][c[4]] + P[5][c[5]] + P[6][c[6]] + P[7][c[7]] + P[8][c[8]] + P[9][c[9]]
                                        P_max = max(P_max, P_sample)

print(P_max)

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
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())))

cand = []
for i in range(1, 2 ** 20):
  for j in range(20):
    cnt = [0] * n
    if i & (1 << j):
      for k in range(n):
        if f[k][j]:
          cnt[k] += 1
    v = 0
    for k in range(n):
      v += p[k][cnt[k]]
    cand.append(v)
    
print(max(cand))

Submission status: Runtime Error

Solution code:
import math

n=int(input())
f=list()
p=list()
ans=-10**10
for i in range(n):
    f.append(list(map(int,input().split())))
for i in range(n):
    p.append(list(map(int,input().split())))
for i in range(1,1<<10):
    shop=list()
    cnt=[0]*n
    tmp=0
    for j in range(10):
        if i&(1<<j):
            shop.append(j)
    for s in range(n):
        for p in shop:
            if(f[s][p]==1):
                cnt+=1
        tmp+=p[s][cnt[s]]
    ans=max(ans,tmp)
print(ans)

Submission status: Runtime Error

Solution code:
import itertools
import numpy as np
mylist = [0, 1]
n = int(input().rstrip())

mise = [list(map(int, input().rstrip().split())) for i in range(n)]
mine = [list(map(int, input().rstrip().split())) for i in range(n)]

maxnum = - float('inf')
for i in itertools.product(mylist, repeat = 10):
    if sum(i) == 0:
        continue
    sell = 0
    for j, k in zip(mise, mine):
        temp = 0
        for l in range(10):
            if j[l] == i[l] and j[l] == 1:
                temp += 1
        sell += k[temp]
    maxnum = max(maxnum, sell)
print(maxnum)

Submission status: Runtime Error

Solution code:
n=I()
op=[LI() for i in range(n)]
pro=[LI() for i in range(n)]
vals=[]
for j in range(1,2**10):
    ans=0
    common=[0 for i in range(n)]
    for k in range(n):
        for i in range(10):
            x=(j>>i) %2
            common[k]+=x*op[k][i]
        ans+=pro[k][common[k]]
    vals.append(ans)
print(max(vals))

Submission status: Runtime Error

Solution code:
N=int(input())
F=[ [[0 for _ in range(2)] for _ in range(5)] for _ in range(N)]
P= [[0 for _ in range(10)] for _ in range(N)]
total= [[0 for _ in range(5)] for _ in range(2)]

for i in range(N):
  tmp=list( map(int,input().split()) )
  for j in range(5):
    for k in range(2):
      F[i][j][k]=tmp[j+k]
for i in range(N):
  P[i]=list(map(int,input().split()))

for i in range(N):
  tmp=0
  for j in range(5):
    for k in range(2):
      tmp +=

Submission status: Runtime Error

Solution code:
def main():
    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)]
    bit = 1<<10 #全探索2**10
    res = -10**10
    for i in range(1,bit):
        chk = [0]*n
        cnt = 0
        for j in range(10): # 10回分有無判定
            if (i>>j)&1: # 最下位bit判定
                for k in range(n):
                    if f[k][j] == 1:
                        chk[k] += 1
        for l in range(10):
            cnt += p[l][chk[l]]
        res = max(res,cnt)
    print(res)

if __name__ == '__main__':
    main()

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)]

s = [list(map(int,bin(x)[2:].zfill(10))) for x in range(2**10)]
s.pop(0)
c = 0
ans = 0
max = -10000000
for k in range(2**10-1):
    for i in range(n):
        for j in range(10):
            c += f[i][j]*s[k][j]
        ans += p[i][c+1]
        c=0
    if ans > max:
        max = ans
    ans = 0
print(max)

Submission status: Runtime Error

Solution code:
import numpy as np
N = int(input())

ARR = []

for i in range(N):
    ARR.append([int(s) for s in input().split(" ")])

PRR = []

for i in range(N):
    PRR.append([int(s) for s in input().split(" ")])

def calculate(n, arr, prr):
    arr = np.array(arr)

    brr = []
    for i in range(1,2 ** 10):

        mask = np.zeros(10)
        for j in range(0, 10):
            m = i >> j & 1
            mask[9-j] = m
        s = np.count_nonzero(arr == mask)

        sum = 0
        for _i in range(n):
            sum = sum + prr[_i][s[_i]]

        brr.append(sum)


    return brr

result = calculate(N, ARR, PRR)
print(max(result))

Submission status: Runtime Error

Solution code:
import numpy as np
N = int(input())

ARR = []

for i in range(N):
    ARR.append([int(s) for s in input().split(" ")])

PRR = []

for i in range(N):
    PRR.append([int(s) for s in input().split(" ")])

def calculate(n, arr, prr):
    arr = np.array(arr)

    brr = []
    for i in range(1,2 ** 10):

        mask = np.zeros(10)
        for j in range(0, 10):
            m = i >> j & 1
            mask[9-j] = m
        s = np.count_nonzero((arr == mask) & (arr == 1))

        sum = 0
        for _i in range(n):
            sum = sum + prr[_i][s[_i]]

        brr.append(sum)


    return brr

result = calculate(N, ARR, PRR)
print(max(result))

Submission status: Runtime Error

Solution code:
import numpy as np
N = int(input())

ARR = []

for i in range(N):
    ARR.append([int(s) for s in input().split(" ")])

PRR = []

for i in range(N):
    PRR.append([int(s) for s in input().split(" ")])

def calculate(n, arr, prr):
    arr = np.array(arr)

    brr = []
    for i in range(1,2 ** 10):

        mask = np.zeros(10)
        for j in range(0, 10):
            m = i >> j & 1
            mask[9-j] = m
        s = np.count_nonzero((arr == mask) & (arr == 1),axis=1)

        sum = 0
        for _i in range(n):
            sum = sum + prr[_i][s[_i]]

        brr.append(sum)


    return [1]

result = calculate(N, ARR, PRR)
print(max(result))

Submission status: Runtime Error

Solution code:
import numpy as np
N = int(input())

ARR = []

for i in range(N):
    ARR.append([int(s) for s in input().split(" ")])

PRR = []

for i in range(N):
    PRR.append([int(s) for s in input().split(" ")])

def calculate(n, arr, prr):
    arr = np.array(arr)

    brr = []
    for i in range(1,2 ** 10):

        mask = np.zeros(10)
        for j in range(0, 10):
            m = i >> j & 1
            mask[9-j] = m
        s = np.count_nonzero((arr == mask) & (arr == 1),axis=1)

        sum = 0
        for _i in range(n):
            sum = sum + prr[_i][s[_i]]

        brr.append(sum)


    return brr

result = calculate(N, ARR, PRR)
print(max(result))

Submission status: Runtime Error

Solution code:
import numpy as np
N = int(input())

ARR = []

for i in range(N):
    ARR.append([int(s) for s in input().split(" ")])

PRR = []

for i in range(N):
    PRR.append([int(s) for s in input().split(" ")])

def calculate(n, arr, prr):
    return []

result = calculate(N, ARR, PRR)
print(max(result))

Submission status: Runtime Error

Solution code:
import numpy as np
N = int(input())

ARR = []

for i in range(N):
    ARR.append([int(s) for s in input().split(" ")])

PRR = []

for i in range(N):
    PRR.append([int(s) for s in input().split(" ")])

def calculate(n, arr, prr):
    

    return []

result = calculate(N, ARR, PRR)
print(max(result))

Submission status: Runtime Error

Solution code:
import numpy as np
N = int(input())

ARR = []

for i in range(N):
    ARR.append([int(s) for s in input().split(" ")])

PRR = []

for i in range(N):
    PRR.append([int(s) for s in input().split(" ")])

def calculate(n, arr, prr):
    arr = np.array(arr)


    return []

result = calculate(N, ARR, PRR)
print(max(result))

Submission status: Runtime Error

Solution code:
import numpy as np
N = int(input())

ARR = []

for i in range(N):
    ARR.append([int(s) for s in input().split(" ")])

PRR = []

for i in range(N):
    PRR.append([int(s) for s in input().split(" ")])

def calculate(n, arr, prr):
    arr = np.array(arr)

    brr = []
 
    return brr

result = calculate(N, ARR, PRR)
print(max(result))

Submission status: Runtime Error

Solution code:
import numpy as np
N = int(input())

ARR = []

for i in range(N):
    ARR.append([int(s) for s in input().split(" ")])

PRR = []

for i in range(N):
    PRR.append([int(s) for s in input().split(" ")])

def calculate(n, arr, prr):
    arr = np.array(arr)

    brr = []
    for i in range(1,2 ** 10):

       a = 1


    return brr

result = calculate(N, ARR, PRR)
print(max(result))

Submission status: Runtime Error

Solution code:
import numpy as np
N = int(input())

ARR = []

for i in range(N):
    ARR.append([int(s) for s in input().split(" ")])

PRR = []

for i in range(N):
    PRR.append([int(s) for s in input().split(" ")])

def calculate(n, arr, prr):
    arr = np.array(arr)

    brr = []
    for i in range(1,2 ** 10):

        mask = np.zeros(10)

    return brr

result = calculate(N, ARR, PRR)
print(max(result))

Submission status: Runtime Error

Solution code:
import numpy as np
N = int(input())

ARR = []

for i in range(N):
    ARR.append([int(s) for s in input().split(" ")])

PRR = []

for i in range(N):
    PRR.append([int(s) for s in input().split(" ")])

def calculate(n, arr, prr):
    arr = np.array(arr)

    brr = []
    for i in range(1,2 ** 10):

        mask = np.zeros(10)
        for j in range(0, 10):
            m = i >> j & 1
            mask[9-j] = m


    return brr

result = calculate(N, ARR, PRR)
print(max(result))

Submission status: Runtime Error

Solution code:
import numpy as np
N = int(input())

ARR = []

for i in range(N):
    ARR.append([int(s) for s in input().split(" ")])

PRR = []

for i in range(N):
    PRR.append([int(s) for s in input().split(" ")])

def calculate(n, arr, prr):
    arr = np.array(arr)

    brr = []
    for i in range(1,2 ** 10):

        mask = np.zeros(10)
        for j in range(0, 10):
            m = i >> j & 1
            mask[9-j] = m
        s = np.count_nonzero((arr == mask) & (arr == 1),axis=1)


    return brr

result = calculate(N, ARR, PRR)
print(max(result))

Submission status: Runtime Error

Solution code:
import numpy as np
N = int(input())

ARR = []

for i in range(N):
    ARR.append([int(s) for s in input().split(" ")])

PRR = []

for i in range(N):
    PRR.append([int(s) for s in input().split(" ")])

def calculate(n, arr, prr):
    arr = np.array(arr)

    brr = []
    for i in range(1,2 ** 10):

        mask = np.zeros(10)
        for j in range(0, 10):
            m = i >> j & 1
            mask[9-j] = m
        s = np.count_nonzero((arr == mask) & (arr == 1),axis=1)

        sum = 0
        for _i in range(n):
            sum = sum + prr[_i][s[_i]]

        brr.append(sum)


    return brr

result = calculate(N, ARR, PRR)
print(max(result))

Submission status: Runtime Error

Solution code:

icase=0
if icase==0:
    n=int(input())

    f=[]
    for i in range(n):
        fi=map(int,input().split())
        f.append(fi)
    p=[]
    for i in range(n):
        pi=map(int,input().split())
        p.append(pi)
elif icase==1: 
    n=1
    f=[[1, 1, 0, 1, 0, 0, 0, 1, 0, 1]]
    p=[[3, 4, 5, 6, 7, 8, 9, -2, -3, 4, -2]]
elif icase==2: 
    n=2
    f=[[1, 1, 1, 1, 1, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 1, 1, 1, 1, 1]]
    p=[[0, -2, -2, -2, -2, -2, -1, -1, -1, -1, -1],
       [0, -2, -2, -2, -2, -2, -1, -1, -1, -1, -1]]
elif icase==3: 
    n=3
    f=[[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]]
    p=[[-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]]
    
import itertools
sumpmax=-10**11
for i in itertools.product([0,1], repeat=10):
    r=list(i)
    sump=0
    if sum(r)!=0:
        for jj in range(n):
            ci=0
            for j in range(10):
                ci=ci+r[j]*f[jj][j]
            sump=sump+p[jj][ci]
#            print(sump,r)
        sumpmax=max(sump,sumpmax)
print(sumpmax)

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 j in range(N)]  
max = -9999999999  
for i in range(1, 2**10):
    sum = 0
    for j in range(N):
        count = 0
        for k in range(10):
            if ((i >> k)&1) == 1 and F[j][k] == 1:
                count += 1
        sum += P[j][count]
    max = max(max, sum)  
print(max)

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 j in range(N)]  
max = -9999999999  
for i in range(1, 2**10):
    for j in range(N):
        count = 0
        for k in range(10):
            if ((i >> k)&1) == 1 and F[j][k] == 1:
                count += 1
        sum += P[j][count]
    max = max(max, sum)  
print(max)

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)]

tmp = 0
ans = 0
for i in range(1, 2**10+1):
    tmp = 0
    for j in range(N):
        cnt = 0
        for k in range(10):
            if((i>> k)%2 == 1 and F[j][k] == 1):
                cnt += 1
        tmp += P[j][cnt+1]
    ans = max(ans, tmp)

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)]

num = 0
store = []
second = []
pos = []
ans = 0
min_z = 10**7+1
n = 0
for i in range(N):
    num = F[i].count(1)
    if(max(P[i][:(num+1)]) != P[i][0]):
        ans += max(P[i][:(num+1)])
    else:
        store.append(P[i][0])
        second.append(max(P[i][1:(num+1)]))
        pos.append(i)
if ans:
    for j in pos:
        ans += store[j]
    print(ans)
else:
    for k in range(len(pos)):
        if(store[k]-second[k] < min_z):
            min_z = store[k]-second[k]
            n = k
    ans += second[n]
    for k in range(len(store)):
        if(k == n):
            continue
        ans += store[k]
    print(ans)

Submission status: Runtime Error

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

from itertools import *
first=True
ans=-10**12
for tmp in list(product([0,1], repeat=10)):
    if first:
        first=False
        continue

    for i in range(n):
        cnt=0
        for j in range(10):
            cnt+= tmp[j] & mise[j]
        sm=0
        for i in range(n):
            sm+=p[i][cnt]
        if ans < sm:
            ans=sm
print(ans)