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)]
P = [list(map(int, input().split())) for _ in range(N)]
result = 0

for i in range(1024):
    array = []
    num = i
    for _ in range(10):
        array.append(num%2)
        num //= 2

    point = 0
    for j in range(N):
        counter = 0
        for k in range(10):
            if array[k] == 1 and F[j][k] == 1:
                counter += 1

        point += P[j][counter]

    result = max(result, point)

print(result)

Submission status: Wrong Answer

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

for i in range(N):
    P.append(list(map(int,input().split())))
    
    
def calc_profit(open_list):
    count = [0 for i in range(N)]
    for i in range(10):
        if open_list[i]:
            for j in range(N):
                if F[j][i]==1:
                    count[j]+=1
    profit=0
    for i in range(N):
        profit+=P[i][count[i]]
    return profit


def get_max(l):
    if len(l)==10:
        return calc_profit(l)
    else:
        return max(get_max(l+[True]),get_max(l+[False]))
print(get_max([]))

Submission status: Wrong Answer

Solution code:
N = int(input())
F = []
P = []
maxl = -10000000
for i in range(N):
  L = list(map(int,input().split()))
  F.append(L)
for i in range(N):
  L = list(map(int,input().split()))
  maxl = min(maxl,min(L))
  P.append(L)
k=1
K = [0,0,0,0,0,0,0,0,0,0]
while k<1024:
  maxll=0
  d = k
  for i in range(10):
    K[i] = d%2
    d = d//2
  k+=1
  for Ni in range(N):
    count=0
    for i in range(10):
      if F[Ni][i] and K[i]:
        count+=1
    maxll+=P[Ni][count]
  maxl = max(maxll,maxl)
print(maxl)

Submission status: Wrong Answer

Solution code:
N = int(input())
F = []
P = []
maxl = 0
M = [0,0,0,0,0,0,0,0,0,0]
for i in range(N):
  L = list(map(int,input().split()))
  for j in range(10):
    if M[j]==0 and L[j]!=0:
      M[j]+=1
  F.append(L)
for i in range(N):
  L = list(map(int,input().split()))
  maxl = min(maxl,min(L))
  P.append(L)
k=1
K = [0,0,0,0,0,0,0,0,0,0]
while k<1024:
  maxll=0
  d = k
  for i in range(10):
    K[i] = d%2
    d = d//2
  k+=1
  if K!=M:
    for Ni in range(N):
      count=0
      for i in range(10):
        if F[Ni][i] and K[i]:
          count+=1
      maxll+=P[Ni][count]
    maxl = max(maxll,maxl)
print(maxl)

Submission status: Wrong Answer

Solution code:
N = int(input())
F = []
P = []
maxl = 0
for i in range(N):
  L = list(map(int,input().split()))
  F.append(L)
for i in range(N):
  L = list(map(int,input().split()))
  maxl = min(maxl,min(L))
  P.append(L)
k=1
K = [0,0,0,0,0,0,0,0,0,0]
while k<1024:
  maxll=0
  d = k
  for i in range(10):
    K[i] = d%2
    d = d//2
  k+=1
  for Ni in range(N):
    count=0
    for i in range(10):
      if F[Ni][i] and K[i]:
        count+=1
    maxll+=P[Ni][count]
  maxl = max(maxll,maxl)
print(maxl)

Submission status: Wrong Answer

Solution code:
# encoding: utf-8
N = int(input())
F = [list(map(int, input().split())) for i in range(N)]
P = [list(map(int, input().split())) for i in range(N)]

def Fidx(i, j): return 2 * i + j

def bc10(num):
    num_tmp = num
    ret = 0
    for i in range(10):
        if num_tmp % 2: ret += 1
        num_tmp = num_tmp >> 1
    return ret

# re-arrange enemy infomation
F_mask = [0] * N
for i, F_row in enumerate(F): F_mask[i] += sum([(2 ** j) * item for j, item in enumerate(F_row)])

ans = - (10 ** 7) * N
for case in range(3 ** 5):
    # decide joisino-onechan's status
    joisino = 0
    case_tmp = case
    for i in range(5):
        joisino += ((case_tmp % 3 + 1) << (2 * i)) # 01, 10, 11
        case_tmp = case_tmp // 3
    # calc profit
    profit = 0
    for i, enemy in enumerate(F_mask): profit += P[i][bc10(joisino & enemy)]
    # update
    if ans < profit: ans = profit

print(ans)

Submission status: Wrong Answer

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

#k[i]はi番目の時間帯に出店している店の数
#for i in range(10):
#    for j in range(N):
#        k[i]+=F[j][i]

ans=-10**8
for i in range(1,2**10):
    tmp=0
    s='{0:010b}'.format(i)
    for k in range(N):
        c=0
        for j in range(10):
            if (int(s[j])+F[k][j])==2:
                c+=1
        tmp+=P[k][c]
    ans=max(ans,tmp)
    
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
def 解():
    input = sys.stdin.readline
    iN = int(input())
    aF = [0]*iN
    aP = [0]*iN
    for i in range(iN):
        aF[i] = int(input().rstrip().replace(' ',''),2)
    for i in range(iN):
        aP[i] = [int(_) for  _ in input().split()]
    iD = 2**10
    iMax = -1*(10**8)
    for i in range(1,iD):
        iM = 0
        for j in range(iN):
            iM += aP[j][bin(aF[j] & i).count("1")]
        if iMax < iM:
            iMax = iM
    print(iMax)
解()

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)]
total = -10**8
for i in range(1, 1024):
    x = list(map(int, list(format(i, '010b'))))
    tmp = 0
    for j in range(n):
        a = 0
        for k in range(10):
            a += x[k] * f[j][k]
        tmp += p[j][a]
    total = max(tmp, total)
print(total)

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)]
total = -10**8
for i in range(1, 1024):
    x = list(map(int, list(format(i, '010b'))))
    tmp = 0
    for j in range(n):
        a = 0
        for k in range(10):
            if x[k] and f[j][k]:
                a += 1
        tmp += p[j][a]
    total = max(tmp, total)
print(total)

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)]
total = -10**7
for i in range(1, 1024):
    x = format(i, '010b')
    tmp = 0
    for j in range(n):
        a = 0
        for k in range(10):
            if int(x[k]) and f[j][k]:
                a += 1
        tmp += p[j][a]
    total = max(tmp, total)
print(total)

Submission status: Wrong Answer

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

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

print(profit)

Submission status: Wrong Answer

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

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

print(profit)

Submission status: Wrong Answer

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

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

print(profit)

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 = -float('inf')
for k in range(1,1<<10): #1000個の空き状態について調べる2^10
  tmp = 0
  for fs,ps in zip(F,P): #お店の空きと利益
    cnt = 0

    for b in range(10):
      if (k>>b)&1 and fs[b]: #空き情報が一致していたら（kのb番目が1なら=お店が空いていれば）
        cnt += 1             #カウント1
      tmp = ps[cnt]          #


  ans = max(tmp, ans)
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
# F[y][x]: y行目、x文字目
F = [list(map(int, input().split())) for _ in range(N)]
# P[y][x]: y行目、x文字目
P = [list(map(int, input().split())) for _ in range(N)]

max_num = -10000001
sum = 0

for i in range(1024):
    if i == 0:
        continue
    b = bin(i)
    for n in range(N):
        f = F[n]
        s = ""
        for _n in range(10):
            s += str(f[_n])
        s = "0b" + s
        and_num = int(b, 0) & int(s, 0)
        match_nums = list(format(and_num, 'b'))
        match_num = 0
        for _n in match_nums:
            if int(_n) == 1:
                match_num += 1
        sum += P[n][match_num]
    if sum > max_num:
        max_num = sum
    sum = 0
print(max_num)

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 = []
for i in range(1, 2**10 + 1):
    index = list(map(int, list(bin(i))[2:]))
    kaburi = [sum([i * f for i, f in zip(index, F[n])]) for n in range(N)]
    res.append(sum([P[n][k] for n, k in zip(range(N), kaburi)]))

print(max(res))

Submission status: Wrong Answer

Solution code:
#ABC080C
import numpy as np
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())))

ans=-1*pow(10,10)
ans_tmp=0
Self=[0]*10
c=0
#営業時間を仮定
for i in range(pow(2,10)-1):
    ans_tmp=0
    if i !=0:
        i_tmp = i
        for j in range(10):
            Self[j]=i_tmp//pow(2,9-j)
            i_tmp-=Self[j]*pow(2,9-j)
        for k in range(N):
            c=np.dot(F[k],Self)
            ans_tmp+=P[k][c]
        if ans<ans_tmp:
            ans=ans_tmp
print(ans)

Submission status: Wrong Answer

Solution code:
#ABC080C
import numpy as np
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())))

ans=-1*pow(10,9)
ans_tmp=0
Self=[0]*10
c=0
#営業時間を仮定
for i in range(pow(2,10)-1):
    ans_tmp=0
    if i !=0:
        i_tmp = i
        for j in range(10):
            Self[j]=i_tmp//pow(2,9-j)
            i_tmp-=Self[j]*pow(2,9-j)
        for k in range(N):
            c=np.dot(F[k],Self)
            ans_tmp+=P[k][c]
        if ans<ans_tmp:
            ans=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)]
P_list = []


for i in range(1, 2 ** 10 - 1):
    a = list(bin(i))[2::]
    while len(a) < 10:
        a = ["0"] + a
    P_list.append(a)
finalans = -1000000000000000
for i in P_list:
    ans = 0
    cnt = [0 for i in range(N)]
    for j in range(10):
        if i[j] == "1":
            for k in range(N):
                if F[k][j] == 1:
                    cnt[k] += 1
    for j in range(N):
        ans += P[j][cnt[j]]
    #print(ans)
    finalans = max(finalans, ans)

print(finalans)

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


for i in range(1, 2 ** 10 - 1):
    a = list(bin(i))[2::]
    while len(a) < 10:
        a = ["0"] + a
    P_list.append(a)
finalans = -100000000000
for i in P_list:
    ans = 0
    cnt = [0 for i in range(N)]
    for j in range(10):
        if i[j] == "1":
            for k in range(N):
                if F[k][j] == 1:
                    cnt[k] += 1
    for j in range(N):
        ans += P[j][cnt[j]]
    #print(ans)
    finalans = max(finalans, ans)

print(finalans)

Submission status: Wrong Answer

Solution code:
#ABC080C
import numpy as np
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())))

ans=-1*pow(10,7)
ans_tmp=0
Self=[0]*10
c=0
#営業時間を仮定
for i in range(pow(2,10)-1):
    ans_tmp=0
    if i !=0:
        i_tmp = i
        for j in range(10):
            Self[j]=i_tmp//pow(2,9-j)
            i_tmp-=Self[j]*pow(2,9-j)
        for k in range(N):
            c=np.dot(F[k],Self)
            ans_tmp+=P[k][c]
        if ans<ans_tmp:
            ans=ans_tmp
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from itertools import product
N = int(input())
F = []
for i in range(N):
    F.append([int(i) for i in input().split()])
P = []
for i in range(N):
    P.append([int(i) for i in input().split()])

ans = -float('inf')

def culc(F, P, l):
    ret = 0
    for i in range(N):
        c = sum([j == k == 1 for j, k in zip(F[i], l)])
        ret += P[i][c]
    return ret

for l in product([0,1],repeat=10):
    ans = max(ans, culc(F, P, l))
print(ans)

Submission status: Wrong Answer

Solution code:
f = lambda: list(map(int,input().split()))

n = int(input())
F = [f() for _ in range(n)]
P = [f() for _ in range(n)]

from itertools import product
mul = product((0, 1), repeat=10)

ans = -float('inf')
for m in mul:
    ben = 0
    for shop in range(n):
        op = sum(m[j] & F[shop][j] for j in range(10))
        ben += P[shop][op]
    ans = max(ans,ben)
print(ans)

Submission status: Wrong Answer

Solution code:
def solver():
    import itertools
    N = int(input())

    # implements
    Fs = [list(map(int, input().split())) for n in range(N)]
    Ps = [list(map(int, input().split())) for n in range(N)]

    # joisino姉がお店を開く全組み合わせ
    Xs = itertools.product([0,1], repeat=10)
    next(Xs) # すべて0を除く

    ans = (-10**7)*10
    for x in Xs:
        profit = 0
        for n in range(N):
            c = 0
            for a, b in zip(x, Fs[n]):
                if a == b == 1:
                    c += 1
            profit += Ps[n][c]
        ans = max(ans, profit)
    print(ans)


if __name__ == "__main__":
    solver()

Submission status: Wrong Answer

Solution code:
n = int(input())
f = [int(input().replace(' ', ''), 2) for i in range(n)]
p = []
for i in range(n):
    p.append([int(v) for v in input().split()])

ans = -100000000
for store in range(1, 1024):
    p_sum = 0
    for i, v in enumerate(f):
        c = v & store
        p_sum += p[i][bin(c).count('1')]
    ans = max(ans, p_sum)

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
F = [0 for i in range(N)]
P = [0 for i in range(N)]
for i in range(N):
  F[i] = [int(x) for x in input().split()]
for i in range(N):
  P[i] = [int(x) for x in input().split()]
ans = 0
for c in range(1, 2 ** 10):
  pat = ('0' * 9 + bin(c)[2:])[-10:]
  ans = max(sum([P[i][sum([F[i][j] * int(pat[j]) for j in range(10)])] for i in range(N)]), ans)
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


# --------------------------------------------

dp = None


def main():
    N = int(input())
    F = [li_input() for _ in range(N)]
    P = [li_input() for _ in range(N)]

    ans = (-1) * (10**100)

    for i in range(1, 1024):
        B = to_bin(i)

        tmpans = 0
        for j in range(len(F)):
            match = 0
            for other, joisino in zip(F[j], B):
                if other == int(joisino) == 1:
                    match += 1

            tmpans += P[j][match]

        ans = max(ans, tmpans)

    print(ans)


main()

Submission status: Wrong Answer

Solution code:
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


# --------------------------------------------

dp = None


def main():
    N = int(input())
    F = [li_input() for _ in range(N)]
    P = [li_input() for _ in range(N)]

    ans = (-1) * (10**100)

    for i in range(1, 1025):
        B = to_bin(i)

        tmpans = 0
        for j in range(len(F)):
            match = 0
            for other, joisino in zip(F[j], B):
                if other == int(joisino) == 1:
                    match += 1

            tmpans += P[j][match]

        ans = max(ans, tmpans)

    print(ans)


main()

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)]
ans = - 10**7
for X in product( range(2), repeat = 10):
    if X == tuple([0]*10):
        pass
    else:
        c = 0
        for i in range(N):
            n = 0
            for j in range(10):
                if F[i][j] == 1 and X[j] == 1:
                    n += 1
            c += P[i][n]
        ans = max(ans, c)
print(ans)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

    max_profit = -10000001

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

Submission status: Wrong Answer

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

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

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

    max_profit = -10000000

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

Submission status: Wrong Answer

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

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

    max_profit = -10000000

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

Submission status: Wrong Answer

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

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

    max_profit = -10000000

    for i in range(1, 2 ** 10):
        profit = 0
        binary = [0] * 10
        now = i
        for j in range(10):
            binary[j] = now % 2
            now = now // 2
        #binary = '{:010b}'.format(i)
        #binary = [int(k) for k in list(binary)]
        for j in range(n):
            one_cnt = 0
            for l in range(10):
                if binary[l] * f_list[j][l] == 1:
                    one_cnt += 1
            profit += p_list[j][one_cnt]
        if max_profit < profit:
            max_profit = profit
    print(max_profit)
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

    max_profit = -10000001

    for i in range(1, 2 ** 10):
        profit = 0
        for j in range(n):
            one_cnt = 0
            binary = '{:010b}'.format(i)
            binary = [int(k) for k in list(binary)]
            for l in range(10):
                if binary[l] * f_list[j][l] == 1:
                    one_cnt += 1
            profit += p_list[j][one_cnt]
        if max_profit < profit:
            max_profit = profit
    print(max_profit)
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

    max_profit = -10000000

    for i in range(1, 2 ** 10):
        for j in range(len(f_list)):
            one_cnt = 0
            binary = '{:010b}'.format(i)
            binary = [int(k) for k in list(binary)]
            for l in range(10):
                if binary[l] == f_list[j][l] and binary[l] == 1:
                    one_cnt += 1
            if j == 0:
                profit = p_list[j][one_cnt]
            else:
                profit += p_list[j][one_cnt]
        if max_profit < profit:
            max_profit = profit
    print(max_profit)
            
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

    max_profit = -10000000

    for i in range(1, 2 ** 10):
        profit = 0
        for j in range(len(f_list)):
            one_cnt = 0
            binary = '{:010b}'.format(i)
            binary = [int(k) for k in list(binary)]
            for l in range(10):
                if binary[l] == f_list[j][l] and binary[l] == 1:
                    one_cnt += 1
            profit += p_list[j][one_cnt]
        if max_profit < profit:
            max_profit = profit
    print(max_profit)
            
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N=int(input())
ans=-10*9
s=["".join(list(input().split())) for i in range(N)]
t=[list(map(int,input().split())) for i in range(N)]
for j in range(1,1024):
    q=0
    for i in range(len(s)):
        q+=t[i][(bin(int(s[i],2)&j)).count("1")]
    ans=max(ans,q)
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
ans=-10*9
s=["".join(list(input().split())) for i in range(N)]
t=[list(map(int,input().split())) for i in range(N)]
for j in range(1,1024):
    q=0
    for i in range(len(s)):
        q+=t[i][(((bin(int(s[i],2)&j)).count("1")))]
    ans=max(ans,q)
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
ans=-10*9
s=["".join(list(input().split())) for i in range(N)]
t=[list(map(int,input().split())) for i in range(N)]
for j in range(1,1024):
    q=0
    for i in range(len(s)):
        q+=t[i][(((bin(int(s[i],2)&j)).count("1")))]
        ans=max(ans,q)
print(ans)

Submission status: Wrong Answer

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

f_list = [sum(i) for i in f]

p_list = []

for l, i in zip(p, f_list):
    p_list.append(l[:i+1])

false_ans = 0
list1 = []
best_ans = 0

for p in p_list:
    false_ans += p[0]
    list1.append(p[1])
    best_ans += max(p)

if best_ans == false_ans:
    print(max(list1))
else:
    print(best_ans)

Submission status: Wrong Answer

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

f_list = [sum(i) for i in f]

p_list = []

for l, i in zip(p, f_list):
    p_list.append(l[:i+1])

false_ans = 0
list1 = []
best_ans = 0

for p in p_list:
    false_ans += p[0]
    list1.append(p[1])
    best_ans = max(p)

if best_ans == false_ans:
    print(max(list1))
else:
    print(best_ans)