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 _ in range(n)]
f=[list(input().split()) for _ in range(n)]
p=[list(map(int,input().split())) for _ in range(n)]
ans=-1000000007
for mask in range(1,1<<10):
    tmp=0
    for i in range(n):
        count=0
        for j in bin(mask&int(str("".join(f[i])),2))[2:]:
            count+=1
        tmp+=p[i][count]
    ans=max(ans,tmp)
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
f = [sum(list(map(int,input().split()))) for _ in range(n)]
p = [list(map(int,input().split())) for _ in range(n)]
ans = []
zero_list = 0
for i in range(n):
  for j in range(f[i]+1):
    if j == 0:
      cnt = p[i][j]
      zero_cnt = True
    else:
      if p[i][j] > cnt:
        cnt = p[i][j]
        zero_cnt = None
      else:
        pass
  if zero_cnt:
    zero_list += 1
  ans.append(cnt)
if zero_list != n:
  print(sum(ans))
else:
  ans2 = []
  for i in range(n):
    ans2.append(sum(ans)-p[i][0]+p[i][1])
  print(max(ans2))

Submission status: Wrong Answer

Solution code:
n = int(input())
f = [sum(list(map(int,input().split()))) for _ in range(n)]
p = [list(map(int,input().split())) for _ in range(n)]
ans = []
zero_list = 0
for i in range(n):
  for j in range(f[i]+1):
    if j == 0:
      cnt = p[i][j]
      zero_cnt = True
    else:
      if p[i][j] >= cnt:
        cnt = p[i][j]
        zero_cnt = None
      else:
        pass
  if zero_cnt:
    zero_list += 1
  ans.append(cnt)
if zero_list != n:
  print(sum(ans))
else:
  cnt = 0
  for i in range(n):
    cnt += p[i][0]
  ans2 = []
  for i in range(n):
    ans2.append(cnt-p[i][0]+p[i][1])
  print(max(ans2))

Submission status: Wrong Answer

Solution code:
n = int(input())
f = [sum(list(map(int,input().split()))) for _ in range(n)]
p = [list(map(int,input().split())) for _ in range(n)]
ans = []
zero_list = 0
for i in range(n):
  for j in range(f[i]+1):
    if j == 0:
      cnt = p[i][j]
      zero_cnt = True
    else:
      if p[i][j] >= cnt:
        cnt = p[i][j]
        zero_cnt = None
      else:
        pass
  if zero_cnt:
    zero_list += 1
  ans.append(cnt)
if zero_list != n:
  print(sum(ans))
else:
  cnt = 0
  for i in range(n):
    cnt += p[i][0]
  ans = []
  for i in range(n):
    ans.append(cnt-p[i][0]+p[i][1])
  print(max(ans))

Submission status: Wrong Answer

Solution code:
n = int(input())
f = [sum(list(map(int,input().split()))) for _ in range(n)]
p = [list(map(int,input().split())) for _ in range(n)]
ans = []
zero_list = []
for i in range(n):
  for j in range(f[i]+1):
    if j == 0:
      cnt = p[i][j]
      zero_cnt = True
    else:
      if p[i][j] >= cnt:
        cnt = p[i][j]
        zero_cnt = None
      else:
        pass
  if zero_cnt:
    zero_list.append(0)
  ans.append(cnt)
if len(zero_list) < n:
  print(sum(ans))
else:
  cnt = 0
  for i in range(n):
    cnt += p[i][0]
  ans = []
  for i in range(n):
    ans.append(cnt-p[i][0]+p[i][1])
  print(max(ans))

Submission status: Wrong Answer

Solution code:
N = int(input())
 
F = []
 
for _ in range(N):
    f = list(input().strip().split())
    F.append(int("".join(f), 2))

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

ans = -10**9+7

for i in range(1,2**10):
    candi = 0
    for j in range(N):
        tmp = i & F[j]
        p = format(tmp, 'b').count("1")
        candi += P[j][p]
    if candi == 0:
        foo = 1
    ans = max(ans,candi) 
    
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
 
F = []
 
for _ in range(N):
    f = list(input().strip().split())
    F.append(int("".join(f), 2))
 
P = [list(map(int, input().split())) for _ in range(N)]

ans = -10**9+7

for i in range(1,2**10):
    candi = 0
    for j in range(N):
        tmp = i & F[j]
        p = format(tmp, 'b').count("1")
        candi += P[j][p]
    ans = max(ans,candi) 
    
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
 
F = []
 
for _ in range(N):
    f = list(input().strip().split())
    F.append(int("".join(f), 2))
 
P = [list(map(int, input().split())) for _ in range(N)]

ans = -10**9+7

for i in range(1,2**10+1):
    candi = 0
    for j in range(N):
        tmp = i & F[j]
        p = format(tmp, 'b').count("1")
        candi += P[j][p]
    ans = max(ans,candi) 
    
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
opened = [int('0b' + input().replace(' ', '')[::-1], 2) for i in range(n)]
prise = [list(map(int, input().split())) for i in range(n)]

ans = -float('INF')
for i in range(1,1<<10-1):
    cnt = [0 for i in range(n)]
    for j in range(10):
        if 1<<j & i:
            continue
        for k in range(n):
            if 1<<j & opened[k]:
                cnt[k] += 1
    tmp = sum([prise[k][cnt[k]] for k in range(n)])
    if tmp > ans:
        ans = tmp
print(ans)
# print(bin(2^10-1))
# [print(bin(i)) for i in opened]

Submission status: Wrong Answer

Solution code:
n = int(input())
# frr = [
#     [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]
# ]
#
# prr = [
#     [-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],
# ]

frr = []

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

prr = []

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


res = []
for i in range(1,2 ** 11):
    count = [0 for s in range(n)]

    mask = []
    for j in range(10):
        m =  i >> j & 1
        if m == 1:
            for k in range(n):
                if frr[k][j] == 1:
                    count[k] = count[k] + 1

    mm = []
    for index,c in enumerate(count):
        mm.append(prr[index][c])

    res.append(sum(mm))

print(max(res))

Submission status: Wrong Answer

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

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 [1]

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

Submission status: Wrong Answer

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 [1]

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

Submission status: Wrong Answer

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 [1]

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

Submission status: Wrong Answer

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 [1]

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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 = -float('inf')
for i in range(1, 1 << 10):
    bit = i
    profit = 0
    for j in range(N):
        cnt = sum(F[j][k] & (bit >> j) for k in range(10))
        profit += P[j][cnt]
    ans = max(ans, profit)

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
max_num = -10**8
stores = {}

for i in range(n):
    stores[i] =[int('0b'+''.join(input().split()), 2)]
for i in range(n):
    stores[i].append(list(map(int, input().split())))
for i in range(1, 1024):
    total_sum = 0
    for j in range(n):
        common_open_time = bin(stores[j][0] & i).count('1')
        total_sum += stores[j][1][common_open_time]
    max_num = max(total_sum, max_num)
print(max_num)

Submission status: Wrong Answer

Solution code:
INF = 100000000000

from itertools import product
N = int(input())
is_opens = []
all_open = [0 for i in range(10)]

for n in range(N):
  l = list(map(int, input().split()))
  for i in range(len(l)):
    all_open[i] = 1 if l[i] == 1 else all_open[i] 
  is_opens.append(l)
must_true = set([i for i in range(len(all_open)) if all_open[i] == 0])

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

patterns = product([0,1], repeat=10)
ans = -INF
for pattern in patterns:
  trues = set([i for i in range(len(pattern)) if pattern[i] == 1])
  if not must_true.issubset(trues) or trues == set():
    continue 

  tmp = 0
  for n in range(N):
    count = sum([1 for i in range(10) if pattern[i] == is_opens[n][i]])
    value = values[n][count]
    tmp += value
  ans = max(ans, tmp)

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=0
for i in range(1,2**10):
  res=0
  for j in range(n):
    cnt=0
    for k in range(10):
      if (i>>k)&1==f[j][k]==1:
        cnt+=1
    res+=p[j][cnt]
  ans=max(ans,res)
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=0
for i in range(1,2**10):
  res=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
    res+=p[j][cnt]
  ans=max(ans,res)
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=0
for i in range(1,2**10):
  op=[0]*10
  res=0
  for j in range(10):
    if i>>j&1:
      op[j]=1
  for j in range(n):
    cnt=0
    for k in range(10):
      if op[k]&f[j][k]:
        cnt+=1
    res+=p[j][cnt]
  ans=max(ans,res)
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)]
F = []
ans = []
for i in f:
    a = i.count(1)
    F.append(a)


for i in range(n):
    mx = -10 ** 7
    
    for j in range(1, F[i] + 1):
        mx = max(mx, p[i][j])
    ans.append(mx)
#print(sum(ans))
mxa = sum(ans)
#print(mxa)
cnt = []
#print(ans)
for i in range(n):
    tm = ans
    x = tm[i]
    tm[i] = p[i][0]
    #print(sum(tm))
    cnt.append(sum(tm))
    tm[i] = x
#print(cnt)

#print(mxa)
for i in range(n):
    if mxa < cnt[i]:
        mxa = cnt[i]
print(mxa)

Submission status: Wrong Answer

Solution code:
n = int(input())
f = []
p = []
for _ in range(n):
    tmp = [int(x) for x in input().split()]
    f.append(tmp)
for _ in range(n):
    tmp = [int(x) for x in input().split()]
    p.append(tmp)

ans = 0
pikked = False
tmp = []
for i in range(n):
    cnt = f[i].count(1)
    ans += max(p[i][:cnt+1])
    if max(p[i][:cnt+1]) != p[i][0]:
        pikked = True
    tmp.append(p[i][1]-p[i][0])

if not pikked:
    ans += min(tmp)
print(ans)

Submission status: Wrong Answer

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

N = int(input().strip())
F_list = [list(map(int, input().rstrip().split())) for i in range(N)]
P_list = [list(map(int, input().rstrip().split())) for i in range(N)]
#-----

bin_str = format(2**10 - 1 , 'b').zfill(10)

total_profit_list=[]
for x in range(1,2**10 - 1):
    bin_str = format(x, 'b').zfill(10)

    profit=0
    for i in range(N):
        c=0
        for j in range(10):
            if int(bin_str[j]) == F_list[i][j] == 1:
                c += 1
        profit += P_list[i][c]
    
    total_profit_list.append(profit)

print(max(total_profit_list))

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 j in range(N)]  
ma = -9999999999  
for i in range(1, 2**10):
    su = 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
        su += P[j][count]
    ma = max(ma, su)  
print(max)

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=-float('inf')
for i in range(1,2**10):
    tmp=list(map(int,list(format(i, '08b'))))
    p_tmp=[0 for _ in range(n)]
    for i in range(n):
        cnt=0
        for j in range(len(tmp)):
            if tmp[j]==1 and f[i][j]==tmp[j]:
                cnt+=1
        p_tmp[i]=cnt
    P=0
    for k in range(n):
        P+=p[k][p_tmp[k]]
    ans=max(ans,P)
ans=max(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=-float('inf')
for i in range(1,2**10):
    tmp=list(map(int,list(format(i, '08b'))))
    p_tmp=[0 for _ in range(n)]
    for i in range(n):
        cnt=0
        for j in range(len(tmp)):
            if tmp[j]==1 and f[i][j]==tmp[j]:
                cnt+=1
        p_tmp[i]=cnt
    P=0
    for k in range(n):
        P+=p[k][p_tmp[k]]
    ans=max(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=-10**9
for i in range(1,2**10):
    tmp=list(map(int,list(format(i, '08b'))))
    p_tmp=[0 for _ in range(n)]
    for i in range(n):
        cnt=0
        for j in range(len(tmp)):
            if tmp[j]==1 and f[i][j]==tmp[j]:
                cnt+=1
        p_tmp[i]=cnt
    P=0
    for k in range(n):
        P+=p[k][p_tmp[k]]
    ans=max(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 = -10000000
for i in range(1, 2**10):
    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]
    ans = max(ans, tmp)

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 = -10**8
for i in range(1, 2**10):
    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]
    ans = max(ans, tmp)

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)]
mise = []

for i in range(2 ** 10):
	kari = []
	ii = i
	for j in range(10):
		kari.append(ii%2)
		ii = ii//2
	mise.append(kari)
	
mise.pop(0)

ans = -100000000
counter = 0
rieki = 0

for i in range(len(mise)):
	for j in range(len(f)):
		for k in range(10):
			if mise[i][k] == 1 and f[j][k] == 1:
				counter += 1
		rieki += p[j][counter]
		counter = 0
	ans = max(ans,rieki)
	rieki = 0

print(ans)

Submission status: Wrong Answer

Solution code:
#080_C
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):
    l=[]
    for j in range(10):
        if (i>>j)&1:
            l.append(1)
        else:
            l.append(0)
    res=0       
    for j in range(n):
        res+=p[j][sum([f[j][k]*l[k] for k in range(10)])]
    ans=max(ans,res)
    
print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env PyPy3
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
mod=10**9+7
import itertools

def main():
    N=I()
    F=[[0]*10 for _ in range(N)]
    P=[[0]*11 for _ in range(N)]
    
    for i in range(N):
        F[i]=LI()
        
    for i in range(N):
        P[i]=LI()
    
    def calc(L):
        temp=0
        for i in range(N):
            cnt=0
            for j in range(10):
                cnt+=L[j]*F[i][j]
            temp+=P[i][cnt]
            
        return temp
    
    ans=-1*(10**8)
    for ite in itertools.product([0,1], repeat=10):
        if sum(ite)!=0:
            ans=max(ans,calc(ite))

    print(ans)

main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env PyPy3
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
mod=10**9+7
import itertools

def main():
    N=I()
    F=[[0]*10 for _ in range(N)]
    P=[[0]*10 for _ in range(N)]
    
    for i in range(N):
        F[i]=LI()
        
    for i in range(N):
        P[i]=LI()
    
    def calc(L):
        temp=0
        for i in range(N):
            cnt=0
            for j in range(10):
                cnt+=L[j]*F[i][j]
            temp+=P[i][cnt]
            
        return temp
    ans=-1*10**8
    for ite in itertools.product([0,1], repeat=10):
        if sum(ite)!=0:
            ans=max(ans,calc(ite))

    print(ans)

main()

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)]
ans=-10**10
for sp in range(1, 1025):
  total = 0
  for i in range(n):
    b = bin(F[i] & sp)
    total += P[i][b.count('1')]
  ans = max(ans, total)
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)]
ans=-10**7*n
for sp in range(1, 1033):
  total = 0
  for i in range(n):
    b = bin(F[i] & sp)
    total += P[i][b.count('1')]
  ans = max(ans, total)
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)]
ans=-10**10
for sp in range(1, 1033):
  total = 0
  for i in range(n):
    b = bin(F[i] & sp)
    total += P[i][b.count('1')]
  ans = max(ans, total)
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)]
ans=-10**7*n
for sp in range(1, 1033):
  total = 0
  for i in range(n):
    total += P[i][bin(F[i] & sp).count('1')]
  if total>=ans:
    ans = total
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)]
ans=-10**7*n
for sp in range(1, 1033):
  total = 0
  for i in range(n):
    total += P[i][bin(F[i] & sp).count('1')]
  if total>ans:
    ans = total
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)]
ans=-10**7*n
for i in range(1, 1033):
  total = 0
  for j in range(n):
    #k = int(F[j], 2)
    b = bin(F[j] & i)
    total += P[j][b.count('1')]
  if total>ans:
    ans = total
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)]
ans=-10**7*n
for i in range(1, 1033):
  total = 0
  for j in range(n):
    #k = int(F[j], 2)
    b = bin(F[j] & i)
    total += P[j][b.count('1')]
    if total>ans:
      ans = total
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)]
ans = -10**14
for i in range(1, 1033):
  total = 0
  for j in range(n):
    #k = int(F[j], 2)
    b = bin(F[j] & i)
    total += P[j][b.count('1')]
    if total>ans:
      ans = total
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
F = [input().replace(' ','') for _ in range(n)]
P = [list(map(int, input().split())) for _ in range(n)]
ans = -10**12
for i in range(1, 1033):
  total = 0
  for j in range(n):
    k = int(F[j], 2)
    b = bin(k & i)
    total += P[j][b.count('1')]
    if total>ans:
      ans = total
print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    F = [input().replace(' ','') for _ in range(n)]
    P = [list(map(int, input().split())) for _ in range(n)]
    ans = -10**12
    for i in range(1, 1033):
        total = 0
        for j in range(n):
            k = int(F[j], 2)
            b = bin(k & i)
            total += P[j][b.count('1')]
        if total>ans:
            ans = total
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    F = [input().replace(' ','') for _ in range(n)]
    P = [list(map(int, input().split())) for _ in range(n)]
    ans = -10**12
    for i in range(1, 1032):
        total = 0
        for j in range(n):
            k = int(F[j], 2)
            b = bin(k & i)
            cnt = b.count('1')
            total += P[j][cnt]
        if total>ans:
            ans = total
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    F = [input().replace(' ','') for _ in range(n)]
    P = [list(map(int, input().split())) for _ in range(n)]
    ans = -10**10
    for i in range(1, 1033):
        total = 0
        for j in range(n):
            k = int(F[j], 2)
            b = bin(k & i)
            cnt = b.count('1')
            total += P[j][cnt]
        if total>ans:
            ans = total
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    F = [input().split() for _ in range(n)]
    P = [list(map(int, input().split())) for _ in range(n)]
    ans = -10**10
    for i in range(1, 1033):
        total = 0
        for j in range(n):
            num = ''.join(F[j])
            k = int(num, 2)
            b = bin(k & i)
            cnt = b.count('1')
            total += P[j][cnt]
        if total>ans:
            ans = total
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    import sys
    #input = sys.stdin.readline
    sys.setrecursionlimit(10000000)

    from collections import Counter
    from collections import deque

    #dxy = [[0,1],[0,-1],[1,0],[-1,0]]
    #dxy = [[0,1],[0,-1],[1,0],[-1,0],[1,1],[1,-1],[-1,1],[-1,-1]]
    #mod = 1000000007

    n = int(input())
    F = [input().split() for _ in range(n)]
    P = [list(map(int, input().split())) for _ in range(n)]
    ans = -10**10
    for i in range(1, 1033):
        total = 0
        for j in range(n):
            num = ''.join(F[j])
            b = bin(int(num, 2) & i)
            cnt = b.count('1')
            total += P[j][cnt]
        if total>ans:
            ans = total
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    F = [input().split() for _ in range(n)]
    P = [list(map(int, input().split())) for _ in range(n)]
    ans = -10**10
    for i in range(1, 1033):
        total = 0
        for j in range(n):
            num = ''.join(F[j])
            b = bin(int(num, 2) & i)
            cnt = b.count('1')
            total += P[j][cnt]
        if total>ans:
            ans = total
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import itertools
j_shop = list(set(itertools.product(*[[0, 1]]*10)) - set([tuple([0]*10)]))

n = int(input())

D = [[] for _ in range(10)]
from collections import defaultdict
profit = defaultdict(int)


for i in range(n):
    f = list(map(int, input().split()))
    for j in range(10):
        if f[j] == 1:
            D[j].append(i)
            
for i in range(n):
    p = list(map(int, input().split()))
    for j in range(11):
        profit[(i, j)] = p[j]
        
ans = float('-INF')
for js in j_shop:
    temp = defaultdict(int)
    for i in range(10):
        if js[i] == 1:
            for d in D[i]:
                temp[d] += 1
    p = 0
    for k, v in temp.items():
        p += profit[(k, v)]
    ans = max(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)]

#%%
INF = 1<<60
ans = -INF
for st in range(1,1<<10):
    t = st
    state = [0]*10
    for i in range(10):
        state[i] = t%2
        t >>= 1
    
    cur = 0
    for k in range(N):
        tmp = 0
        for i in range(10):
            if F[k][i] == 1 and state[i] == 1:
                tmp += 1
        cur += P[k][tmp]
        ans = max(ans,cur)

print(cur)

Submission status: Wrong Answer

Solution code:
N = int(input())
F = []
for _ in range(N):
    F.append(int(''.join(input().split()), 2))
P = []
for _ in range(N):
    P.append(list(map(int, input().split())))

ans = -100000000
for i in range(1, 2 ** 10):
    sum = 0
    for j, f in enumerate(F):
        cover = i & f
        cnt = 0
        while cover != 0:
            if cover % 2 == 1:
                cnt += 1
            cover //= 2
        sum += P[j][cnt]
    ans = max(sum, ans)

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np

# N 店の数
n = int(input())

# F 店の営業計画
f = [input().replace(" ", "") for i in range(n)]

# P 営業利益
p = [list(map(int, input().split())) for i in range(n)]

p_max = -12345678
for i in range(1, 1024):
    f_b = format(i, '010b')
    p_10 = 0
    for f_1, p_1 in zip(f, p):
        p_cnt = 0
        for j in range(10):
            if f_1[j] == '1' and f_b[j] == '1':
                p_cnt += 1
        p_10 += p_1[p_cnt]
    if p_10 > p_max:
        if p_10 == 0:
            print(str(i))
            break
        p_max = p_10

print(p_max)

Submission status: Wrong Answer

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


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

ans = -(10**7)

"""
自分の店が開く時間帯の組み合わせを用意する.itertools?
その組み合わせの時間帯に営業している店を調べる。for文
店ごとにciをカウントしていく.for文
最後にansに店ごとのPを加算していき、マックスの値を調べる。ans = max(ans,~)
"""
#開いてる時間帯を1、開いてない時間帯を0とすると組み合わせは2**10通り
for i in range(2**10):
    check = [0]*10
    tmp = 0
    for j in range(10):
        if (i>>j)&1: #10個の時間帯で開いてる時間帯を探す
            check[j] = 1
    if any(check)==False:
        continue
    for k in range(N):
        cnt = 0 #同時間帯に営業している数
        for l in range(10):
            if F[k][l] == 1 and check[l] == 1:
                cnt += 1
        tmp += P[k][cnt]
    ans = max(ans,tmp)

print(ans)