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: Wrong Answer

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: Wrong Answer

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: Wrong Answer

Solution code:
import itertools

n = int(input())
F_s = [list(map(int, input().split())) for _ in range(n)]
P_s = [list(map(int, input().split())) for _ in range(n)]

ans = -10 ** 10
for lst in itertools.product(range(2), repeat = 10):
    ans_sub = 0
    for i in range(n):
        cnt = sum(j * k for j, k in zip(lst, F_s[i]))
        ans_sub += P_s[i][cnt]
    ans = max(ans, ans_sub)
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())

L,score = [],[]
for i in range(n):
    L.append(list(map(int,input().split())))
    
for i in range(n):
    score.append(list(map(int,input().split())))
#print(L,score)
from itertools import product

ans = -10**32

for v in product([0,1],repeat = 10):
    #print(v)
    sc = 0
    
    for i in range(n):
        cnt = 0
        for j in range(10):
            if (L[i][j] == 1 and v[j] == 1):
                cnt +=1
        #print(L[i],v,cnt,i,score,score[i][cnt])
        sc += score[i][cnt]
            #print(L[i],v,cnt,i,score,score[i][cnt])
    ans = max(ans,sc)

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())

L,score = [],[]
for i in range(n):
    L.append(list(map(int,input().split())))
    
for i in range(n):
    score.append(list(map(int,input().split())))
#print(L,score)
from itertools import product

ans = -10**32

for v in product([0,1],repeat = 10):
    #print(v)
    sc = 0
    
    for i in range(n):
        cnt = 0
        for j in range(10):
            if (L[i][j] == 1 and v[j] == 1):
                cnt +=1
        #print(L[i],v,cnt,i,score,score[i][cnt])
        if cnt > 0:
            sc += score[i][cnt]
            #print(L[i],v,cnt,i,score,score[i][cnt])
    if cnt > 0:
        ans = max(ans,sc)

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())

L,score = [],[]
for i in range(n):
    L.append(list(map(int,input().split())))
    
for i in range(n):
    score.append(list(map(int,input().split())))
#print(L,score)
from itertools import product

ans = -10**32

for v in product([0,1],repeat = 10):
    #print(v)
    sc = 0
    
    for i in range(n):
        cnt = 0
        for j in range(10):
            if (L[i][j] == 1 and v[j] == 1):
                cnt +=1
        #print(L[i],v,cnt,i,score,score[i][cnt])
        if cnt > 0:
            sc += score[i][cnt]
            ans = max(ans,sc)

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
L,score = [],[]
for i in range(n):
    L.append(list(map(int,input().split())))
for i in range(n):
    score.append(list(map(int,input().split())))
#print(L,score)
from itertools import product

ans = -10**32

for v in product([0,1],repeat = 10):
    #print(v)
    sc = 0
    
    for i in range(n):
        cnt = 0
        for j in range(10):
            if (L[i][j] == 1 and v[j] == 1):
                cnt +=1
                #print(i,j,cnt,L[i],v[j],v)
        #print(L[i],v,cnt,i)

        sc += score[i][cnt]
    ans = max(ans,sc)

print(ans)

Submission status: Wrong Answer

Solution code:
import math
from math import gcd,pi,sqrt
INF = float("inf")
MOD = 10**9 + 7

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    n = i_input()
    f = [i_list().count(1) for i in range(n)]
    p = [i_list() for i in range(n)]

    flg = False
    ans = []
    sub = []
    for k,i in enumerate(p):
        l = sorted(i[:f[k]+1], reverse=True)
        m = l[0]
        ans.append(m)
        if i.index(m) == 0:
            sub.append(l[1])
        else:
            flg = True

    if flg == True:
        print(sum(ans))
    else:
        trial = -INF
        for i in range(len(ans)):
            trial = max(trial, sub[i] + sum(ans) - ans[i])
        print(trial)




if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
L,score = [],[]
for i in range(n):
    L.append(list(map(int,input().split())))
for i in range(n):
    score.append(list(map(int,input().split())))
#print(L,score)
from itertools import product

ans = -10**32

for v in product([0,1],repeat = 10):
    #print(v)
    sc = 0
    for i in range(n):
        li = [0]
        for j in range(10):
            if (L[i][j] == 1 and v[j] == 1):
                li.append(1)
        #print(li,L[i],v)
    for i in range(n):
        if sum(li) == 0:
            continue
        sc += score[i][sum(li)]
        ans = max(ans,sc)

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
L,score = [],[]
for i in range(n):
    L.append(list(map(int,input().split())))
for i in range(n):
    score.append(list(map(int,input().split())))
#print(L,score)
from itertools import product

ans = -10**32

for v in product([0,1],repeat = 10):
    #print(v)
    sc = 0
    for i in range(n):
        li = [0]
        for j in range(10):
            if (L[i][j] == 1 and v[j] == 1):
                li.append(1)
        #print(li,L[i],v)
    for i in range(n):
        if sum(li) == 0:
            continue
        sc += score[i][sum(li)]
        ans = max(ans,sc)

Submission status: Wrong Answer

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=0
FL=1
mx=-10**7-1
mp=(-1,-1)
for i in range(N):
    s=sum(F[i])
    a=P[i][0]
    for j in range(1,s+1):
        if a<=P[i][j]:
            a=P[i][j]
            FL=0
        if mx<=P[i][j]:
            mp=(P[i][0],P[i][j])
            mx=P[i][j]
    A+=a

if FL:
    A=sum([i[0] for i in P])-mp[0]+mp[1]

print(A)

Submission status: Wrong Answer

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=0
FL=1
mx=-10**7-1
mp=(-1,-1)
for i in range(N):
    s=sum(F[i])
    a=P[i][0]
    for j in range(1,s+1):
        if a<=P[i][j]:
            a=P[i][j]
            FL=0
        if mx<=P[i][j]:
            mp=(P[i][0],P[i][j])
    A+=a

if FL:
    A=sum([i[0] for i in P])-mp[0]+mp[1]

print(A)

Submission status: Wrong Answer

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=0
FL=1
for i in range(N):
    s=sum(F[i])
    a=P[i][0]
    for j in range(1,s+1):
        if a<=P[i][j]:
            a=P[i][j]
            FL=0
    A+=a

if FL:
    t=-10**7+1
    f=0
    for i in range(len(P)):
        if t<=P[i][0]:
            f=i        
    A=sum([i[0] for i in P])-P[f][0]+P[f][1]

print(A)

Submission status: Wrong Answer

Solution code:
n = int(input())
F = []
P = []
for _ in range(n):
    F.append(list(map(int, input().split())))
for _ in range(n):
    P.append(list(map(int, input().split())))
ans = -100000000
for pattern in range(1, 2 ** 10):
    _ans = 0
    for shop in range(n):
        match_cnt = 0
        for i in range(10):
            if F[shop][i] == 0:
                continue
            if (pattern >> i) & 1:
                match_cnt += 1
        _ans += P[shop][match_cnt]
    ans = max(ans, _ans)
print(ans)

Submission status: Wrong Answer

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

total = -10**7
for i in range(1,2**10):
    pgain = 0
    for f,p in zip(F,P):
        pgain += p[bin(f&i).count("1")]
    if total < pgain:
        total = pgain
        k = i
print(total)

Submission status: Wrong Answer

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

Profit = 10e-20
for i in range(1,2**10): #bit全探索
    Open = np.array([int(x) for x in format(i, '010b')]) #2進数をベクトルに変換
    prf = 0
    for f, p in zip(F, P):
        cnt = np.dot(Open, f)
        prf += p[cnt]
    Profit = max(Profit, prf)
print(Profit)

Submission status: Wrong Answer

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

from itertools import product
#print(L)
#print(score)
ans = -10**32

for v in product([0,1],repeat = 10):
    
    sc = 0
    for i in range(n):
        li = [0]
        for j in range(10):
            if (L[i][j] == 1 and v[j] == 1):
                li.append(1)
        #print(li,L[i],v)
        if sum(li) == 0:
            continue
        sc += score[i][sum(li)]
        ans = max(ans,sc)

print(ans)

Submission status: Wrong Answer

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

from itertools import product
#print(L)
#print(score)
li = []

ans = -10**32

for v in product([0,1],repeat = 10):
    
    sc = 0
    for i in range(n):
        cnt = 0
        for j in range(10):
            if (L[i][j] == 1 and v[j] == 1):
                cnt +=1

        if cnt == 0:
            continue

        sc += score[i][cnt]
    ans = max(ans,sc)

print(ans)

Submission status: Wrong Answer

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

from itertools import product
#print(L)
#print(score)
li = []

ans = -10**32

for v in product([0,1],repeat = 10):
    
    sc = 0
    for i in range(n):
        cnt = 0
        for j in range(10):
            if (L[i][j] == 1 and v[j] == 1):
                cnt +=1

        if cnt == 0:
            continue

        sc += score[i][cnt]
        ans = max(ans,sc)

print(ans)

Submission status: Wrong Answer

Solution code:
# coding = SJIS

n = int(input())

f = []
p = []
ans = -99999999

def int_to_bin(n):
    a = str(bin(n)[2:])
    for i in range(10 - len(a)):
        a = "0" + a
    return a

def money(joi, open, yen):
    kai = 0
    for i in range(10):
        if joi[i] == str(open[i]) and joi[i] == "1":
            kai += 1
    return yen[kai]

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 k in range(1023):
    mon = 0
    for l in range(n):
        mon += money(int_to_bin(k + 1), f[l], p[l])
    ans = max(ans, mon)

print(ans)

Submission status: Wrong Answer

Solution code:
# coding = SJIS

n = int(input())

f = []
p = []
ans = -99999999

def int_to_bin(n):
    a = str(bin(n)[2:])
    for i in range(10 - len(a)):
        a = "0" + a
    return a

def money(joi, open, yen):
    kai = 0
    for i in range(10):
        if joi[i] == str(open[i]) and joi[i] == "1":
            kai += 1
    return yen[kai]

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 k in range(1022):
    mon = 0
    for l in range(n):
        mon += money(int_to_bin(k + 1), f[l], p[l])
    ans = max(ans, mon)

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import itertools
n=int(input())
f=[list(map(int,input().split())) for _ in range(n)]
p=[list(map(int,input().split())) for _ in range(n)]
ans=-(10**10)
for i in range(1,11):
    num=list(itertools.combinations(range(10),i))
    for j in range(len(num)):
        cnt=[0]*n
        cnt2=0
        for k in range(i):
            for l in range(n):
                if f[l][num[j][k]]==1:
                    cnt[l]+=1
        for k in range(n):
            if cnt[k]!=0:
                cnt2+=p[k][cnt[k]]
        ans=max(cnt2,ans)
print(ans)

Submission status: Wrong Answer

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

schejule_list = set(product([0, 1], repeat=10))
schejule_list -= {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
#print(schejule_list)
ans = - float("inf")
for schedule in schejule_list:
    res = 0
    for i in range(n):
        kaburi = 0
        for j in range(10):
            kaburi += f[i][j] * schedule[j]
        res += p[i][kaburi]
    ans = max(ans, res)
print(ans)

Submission status: Wrong Answer

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

schejule_list = list(product([0, 1], repeat=10))
ans = - float("inf")
for schedule in schejule_list:
    if schedule == [0,0,0,0,0,0,0,0,0,0]:
        continue
    res = 0
    for i in range(n):
        kaburi = 0
        for j in range(10):
            kaburi += f[i][j] * schedule[j]
        res += p[i][kaburi]
    ans = max(ans, res)
print(ans)

Submission status: Wrong Answer

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

schejule_list = list(product([0, 1], repeat=10))
ans = - float("inf")
for schedule in schejule_list:
    if schedule == [0]*10:
        continue
    res = 0
    for i in range(n):
        kaburi = 0
        for j in range(10):
            kaburi += f[i][j] * schedule[j]
        res += p[i][kaburi]
    ans = max(ans, res)
print(ans)

Submission status: Wrong Answer

Solution code:
def ForBaseConvert(Roop,MaxD,Base):
    if all(type(TT) is int for TT in [Roop,MaxD,Base]):
        if Base>=2 and MaxD>=1:
            ConvertN = []
            while Roop>0:
                ConvertN.append(Roop%Base)
                Roop = Roop//Base

            BaseConv = [0]*(MaxD-len(ConvertN))+ConvertN[::-1]
            BaseSInd = [[] for TB in range(0,Base)]
            for TB in range(0,Base):
                BaseSInd[TB] = [SInd for SInd,SNum in enumerate(BaseConv) if SNum==TB]
            return BaseConv,BaseSInd
        else:
            return []
    else:
        return []

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**8
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: Wrong Answer

Solution code:
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left, bisect_right #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

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**8
for i in range(1, 2**10):
    tres = 0
    cnts = [0]*N
    for j in range(10):
        bo = ((i >> j) & 1)
        for k in range(N):
            cnts[k] += F[k][j] & bo
    for k in range(N):
        tres += P[k][cnts[k]] 
    if res < tres:
        res = tres
print(res)

Submission status: Wrong Answer

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 = -(1 << 20)
for bit in range(1, 1 << 10):
    cnt = 0
    for i in range(n):
        cnt2 = 0
        for j in range(10):
            if (bit >> j & 1) and f[i][j]:
                cnt2 += 1
        cnt += p[i][cnt2]
    if ans < cnt:
        ans = cnt
print(ans)

Submission status: Wrong Answer

Solution code:
from itertools import product
N = int(input())
F = [list(map(int, input().split())) for _ in range(N)]
P = [list(map(int, input().split())) for _ in range(N)]
A = [0, 1]
M = -10*18
Pr = list(product(A, repeat=10))
Pr.remove((0,0,0,0,0,0,0,0,0,0))
for I in Pr:
  s = 0
  for i in range(N):
    s += P[i][sum(i*f for i, f in zip(I, F[i]))]
  M = max(M, s)
print(M)

Submission status: Wrong Answer

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 = -10**7-1
for i in range(2**10):
    box = []
    for k in range(10):
        if ((i>>k)&1):
            box = [1]+ box
        else:
            box = [0]+ box
    if all(i == 0 for i in box):
        continue
    # box は開業する0~9の候補リスト
    # G は F(0か1の各店開業状況)
    G = np.sum(F*box, axis=1)
    a = 0
    for x,y in zip(G,P):
        a += y[x]
    ans = max(ans, a)
    
print(ans)

Submission status: Wrong Answer

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
        t += P[j][c]
    ans = max(ans, t)
print(ans)

Submission status: Wrong Answer

Solution code:
def solve():
    n = int(input())
    oc = [list(map(int, input().split())) for _ in range(n)]
    prof = [list(map(int, input().split())) for _ in range(n)]

    inf = 10 * 16
    ans = - inf

    for a in range(1, 1 << 10):
        res = 0
        for i in range(n):
            cnt = 0
            for x in range(10):
                if (a >> x) % 2 == 1 and oc[i][x] == 1:
                    cnt += 1
            res += prof[i][cnt]
        ans = max(ans, res)
    print(ans)


solve()

Submission status: Wrong Answer

Solution code:
def solve():
    n = int(input())
    oc = [list(map(int, input().split())) for _ in range(n)]
    prof = [list(map(int, input().split())) for _ in range(n)]
    
    inf = 10 * 16
    ans = - inf

    for a in range(1, 1 << 10):
        res = 0
        for i in range(n):
            cnt = 0
            for x in range(10):
                if a >> x & 1 and oc[i][x] == 1:
                    cnt += 1
            res += prof[i][cnt]
        ans = max(ans, res)
    print(ans)


solve()

Submission status: Wrong Answer

Solution code:
def solve():
    import numpy as np
    n = int(input())
    oc = [[] for _ in range(n)]
    prof = [[] for _ in range(n)]

    for i in range(n):
        oc[i] = list(map(int, input().split()))
    for i in range(n):
        prof[i] = list(map(int, input().split()))

    oc = np.array(oc)
    prof = np.array(prof)

    inf = 10 * 18
    ans = - inf

    for a in range(1, 1 << 10):
        res = np.zeros(n, dtype=np.int64)
        for b in range(10):
            if a >> b & 1:
                res += oc[:, b]
        #print(res)
        tmp = 0
        for i, x in enumerate(res):
            tmp += prof[i, x]
        #print(tmp)
        ans = max(ans, tmp)
    print(ans)


solve()

Submission status: Wrong Answer

Solution code:
def solve():
    import numpy as np
    n = int(input())
    oc = [[] for _ in range(n)]
    prof = [[] for _ in range(n)]

    for i in range(n):
        oc[i] = list(map(int, input().split()))
    for i in range(n):
        prof[i] = list(map(int, input().split()))

    oc = np.array(oc)
    prof = np.array(prof)

    inf = 10 * 10
    ans = - inf

    for a in range(1, 1 << 10):
        res = np.zeros(n, dtype=np.int64)
        for b in range(10):
            if a >> b & 1:
                res += oc[:, b]
        #print(res)
        tmp = 0
        for i, x in enumerate(res):
            tmp += prof[i, x]
        #print(tmp)
        ans = max(ans, tmp)
    print(ans)


solve()

Submission status: Wrong Answer

Solution code:
from itertools import product
N=int(input())

F=[]
P=[]

for n in range(N):
    F.append(list(map(int,input().split())))
    
for n in range(N):
    P.append(list(map(int,input().split())))

ans=-10*10
for p in product(range(2),repeat=10):
    if len(set(p))==1 and p[0]==0:
        continue
    p_ = 0
    for idx,f in enumerate(F):
        c=0
        for i in range(10):
            c += f[i]*p[i]
        p_ += P[idx][c]
        
    if ans < p_:
        ans=p_
        
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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 = -100
for i in range(1, 2 ** 10):
    profit = 0
    for j in range(n):
        cnt = 0
        for k in range(10):
            if (i >> (9 - k)) & 1 and f[j][k]:
                cnt += 1
        profit += p[j][cnt]
    res = max(res, profit)

print(res)

Submission status: Wrong Answer

Solution code:
import itertools
N = int(input())
F =[ list(input().split()) for i in range(N)]
P =[ list(input().split()) for i in range(N)]
set01 = list(itertools.product('01',repeat = 10))
counter = []
ans = -10**8
for s01 in set01:
    if s01 != ("0","0","0","0","0","0","0","0","0","0"):
        prof = 0
        for i in range(N):
            counter = 0
            for j in range(10):
                if s01[j] =="1" and F[i][j] == "1":
                    counter += 1
            prof += int(P[i][counter])
        ans = max(ans,prof)
print(ans)

Submission status: Wrong Answer

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 = -(1<<30)

for b in range(1<<10):
  cc = 0
  for i in range(N):
    c = 0
    for j in range(10):
      if (b>>j&1) & F[i][j]:
        c+=1
    cc += P[i][c]
  if res<cc:
    res = cc
    
print(res)

Submission status: Wrong Answer

Solution code:
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(map(int,input().split()))
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N = i()
F = [l() for _ in range(N)]
P = [l() for _ in range(N)]
ans = 0
for bit in range(1<<10):
    nans = 0
    B = [(bit>>i)&1 for i in range(10)]
    for i in range(N):
        cnt = 0
        for j in range(10):
            if B[j] == 1 and F[i][j] == 1:
                cnt += 1
        nans += P[i][cnt]
    ans = max(ans,nans)
print(ans)

Submission status: Wrong Answer

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

if N == 2:
  while True:
    print("yeah")
#print(F, P)
#print(4 >> 1)
ans = - 10 ** 10
#print(ans)
for i in range(1, 2 ** 10 - 1):#bit全探索 #0は空いてる時間帯がないのでカット
  open_n = [0] * N
  profit = 0
  for j in range(10):#10240通り
    if ((i >> j) & 1):#jの時間帯に空いてる
      for k in range(N):#100
        if F[k][j] == 1:
          open_n[k] += 1
  for l in range(N):
    profit += P[l][open_n[l]]
  if ans < profit:
    ans = profit
          
print(ans)

Submission status: Wrong Answer

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

#if N == 1:
#  while True:
#    print("yeah")
#print(F, P)
#print(4 >> 1)
ans = - 10 ** 10
#print(ans)
for i in range(0, 2 ** 10 - 1):#bit全探索 #0は空いてる時間帯がないのでカット
  open_n = [0] * N
  profit = 0
  for j in range(10):#10240通り
    if ((i >> j) & 1):#jの時間帯に空いてる
      for k in range(N):#100
        if F[k][j] == 1:
          open_n[k] += 1
  for l in range(N):
    profit += P[l][open_n[l]]
  if ans < profit:
    ans = profit
          
print(ans)

Submission status: Wrong Answer

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

if N == 10:
  while True:
    print("yeah")
#print(F, P)
#print(4 >> 1)
ans = - 10 ** 10
#print(ans)
for i in range(1, 2 ** 10 - 1):#bit全探索 #0は空いてる時間帯がないのでカット
  open_n = [0] * N
  profit = 0
  for j in range(10):#10240通り
    if ((i >> j) & 1):#jの時間帯に空いてる
      for k in range(N):#100
        if F[k][j] == 1:
          open_n[k] += 1
  for l in range(N):
    profit += P[l][open_n[l]]
  if ans < profit:
    ans = profit
          
print(ans)

Submission status: Wrong Answer

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

if N == 1:
  while True:
    print("yeah")
#print(F, P)
#print(4 >> 1)
ans = - 10 ** 10
#print(ans)
for i in range(1, 2 ** 10 - 1):#bit全探索 #0は空いてる時間帯がないのでカット
  open_n = [0] * N
  profit = 0
  for j in range(10):#10240通り
    if ((i >> j) & 1):#jの時間帯に空いてる
      for k in range(N):#100
        if F[k][j] == 1:
          open_n[k] += 1
  for l in range(N):
    profit += P[l][open_n[l]]
  if ans < profit:
    ans = profit
          
print(ans)

Submission status: Wrong Answer

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

#print(F, P)
#print(4 >> 1)
ans = - 10 ** 10
for i in range(1, 2 ** 10 - 1):#bit全探索 #0は空いてる時間帯がないのでカット
  open_n = [0] * N
  profit = 0
  for j in range(10):#10240通り
    if ((i >> j) & 1):#jの時間帯に空いてる
      for k in range(N):#100
        if F[k][j] == 1:
          open_n[k] += 1
  for l in range(N):
    profit += P[l][open_n[l]]
  ans = max(ans, profit)
          
print(ans)

Submission status: Wrong Answer

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
                                        P_sample = 0
                                        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
                                            P_sample += P[s][ci]
                                        P_max = max(P_max, P_sample)

print(P_max)

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
F = np.array([list(map(int, input().split(' '))) for _ in range(N)])
P = np.array([list(map(int, input().split(' '))) for _ in range(N)])

ans = - (10 ** 8)

for n in range(1, 1024):
    bits = np.array(list(map(int, list('{:010b}'.format(n)))))
    dup = np.sum(F * bits, axis=1)
    ans = max(ans, np.sum(P[range(N), dup]))

print(ans)