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:
# -*- coding: utf-8 -*-

import itertools

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

# 重複順列で自分の店の全パターンを出す
me_list = list(itertools.product([True, False], repeat=10))

# 初期値は利益の最小値
me_p = -10000000
# 自分の店の全パターンループ
for i in range(len(me_list)):

    # 一度も営業しないパターンを除く
    if not any(me_list[i]):
        continue

    tmp_p = 0
    # 他店の数でループ
    for j in range(N):

        cnt = 0
        # 月～金のAMPMループ
        for k in range(10):

            # 他店との営業重複カウント
            if me_list[i][k] and F[j][k]:
                cnt += 1
        
        # 各店舗との重複数に応じた利益を合算していく
        tmp_p += P[j][cnt]

    # 合算した利益を現状の最高値と比較して置き換えていく
    me_p = max(me_p, tmp_p)   

print(me_p)

Submission status: Wrong Answer

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

import itertools

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

# 重複順列で自分の店の全パターンを出す
me_list = list(itertools.product([0, 1], repeat=10))

# 初期値は利益の最小値
me_p = -10000000
# 自分の店の全パターンループ
for i in range(len(me_list)):

    # 一度も営業しないパターンを除く
    if not any(me_list[i]):
        continue

    tmp_p = 0
    # 他店の数でループ
    for j in range(N):

        cnt = 0
        # 月～金のAMPMループ
        for k in range(10):

            # 他店との営業重複カウント
            if me_list[i][k] == 1 and F[j][k] == 1:
                cnt += 1
        
        # 各店舗との重複数に応じた利益を合算していく
        tmp_p += P[j][cnt]

    # 合算した利益を現状の最高値と比較して置き換えていく
    me_p = max(me_p, tmp_p)   

print(me_p)

Submission status: Wrong Answer

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

import itertools

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

# 重複順列で自分の店の全パターンを出す
me_list = list(itertools.product([0, 1], repeat=10))

# 初期値は利益の最小値
me_p = -10000000
# 自分の店の全パターンループ
for i in range(len(me_list)):

    # 一度も営業しないパターンを除く
    if i == 0:
        continue

    tmp_p = 0
    # 他店の数でループ
    for j in range(N):

        cnt = 0
        # 月～金のAMPMループ
        for k in range(10):

            # 他店との営業重複カウント
            if me_list[i][k] == 1 and F[j][k] == 1:
                cnt += 1
        
        # 各店舗との重複数に応じた利益を合算していく
        tmp_p += P[j][cnt]

    # 合算した利益を現状の最高値と比較して置き換えていく
    me_p = max(me_p, tmp_p)   

print(me_p)

Submission status: Wrong Answer

Solution code:
N = int(input())
F = []
P = []
ans = -10**8
def cal_same_num(F,temp):
    num_same = 0
    for i in range(10):
        if temp[i] == "1" and F[i] == 1:
            num_same += 1
    return num_same

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

for i in range(1,2**10):
    sum_point = 0
    temp = str(format(i,"b")).zfill(10)
    for j in range(N):
        num_same = cal_same_num(F[j],temp)
        point = P[j][num_same]
        sum_point += point
    ans = max(ans,sum_point)
print(ans)

Submission status: Wrong Answer

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

n = int(input())
F = [list(map(int, input().split())) for _ in range(n)]
P = [list(map(int, input().split())) for _ in range(n)]
ans = -1e9

for sister in range(1, 1024):
    count = 0
    for i in range(n):
        cost_list = list('{:b}'.format(int(''.join(map(str, F[i])), 2) & sister))
        cost = 0
        for j in range(len(cost_list)):
            cost += int(cost_list[j])
        count += P[i][cost]
    ans = max(ans, count)

print(ans)

Submission status: Wrong Answer

Solution code:
from itertools import product

N = int(input())
F = []
P = []
for _ in range(N):
    temp = list(map(int, input().split()))
    F.append([temp[:2], temp[2:4], temp[4:6], temp[6:8], temp[8:]])
for _ in range(N):
    P.append(list(map(int, input().split())))

prod = list(product((0, 1), (0, 1), (0, 1), (0, 1), (0, 1),
                    (0, 1), (0, 1), (0, 1), (0, 1), (0, 1)))
MAX = -float("inf")


def compute(pattern):
    x = 0
    for i in range(N):
        c = 0
        for j in range(5):
            for k in range(2):
                if pattern[j][k] == 1 and F[i][j][k] == 1:
                    c += 1
        x += P[i][c]
    return x


for e in prod:
    pattern = [e[:2], e[2:4], e[4:6], e[6:8], e[8:]]
    if pattern != [[0] * 2 for _ in range(5)]:
        MAX = max(compute(pattern), MAX)

print(MAX)

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

ans = 0
cnt = 0
vmin = -10E7
for i in range(N):
    t = 0
    for j in range(sum(F[i])+1):
        if j > 0 and 0 > P[i][j] and abs(vmin) > abs(P[i][j]):
            vmin = P[i][j]
        if P[i][j] > 0:
            t = max(t, P[i][j])
            cnt += 1
    ans += t
if cnt == 0:
    ans += vmin
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)]

ans = 0
cnt = 0
vmin = -10E7
for i in range(N):
    t = 0
    for j in range(sum(F[i])+1):
        if j > 0:
            vmin = max(vmin, P[i][j])
        if P[i][j] > 0:
            t = max(t, P[i][j])
            cnt += 1
    ans += t
if cnt == 0:
    ans += vmin
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)]

ans = 0
cnt = 0
for i in range(N):
    vmin = -10E7
    t = 0
    for j in range(sum(F[i])+1):
        if j > 0:
            vmin = max(vmin, P[i][j])
        if P[i][j] > 0:
            t = max(t, P[i][j])
            cnt += 1
    ans += t
if cnt == 0:
    ans += vmin
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)]

ans = 0
for i in range(N):
    cnt = 0
    vmin = -10E7
    t = 0
    for j in range(sum(F[i])+1):
        if j > 0:
            vmin = max(vmin, P[i][j])
        if P[i][j] > 0:
            t = max(t, P[i][j])
            cnt += 1
    ans += t
if cnt == 0:
    ans += vmin
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
F = [list(map(int, input().split())) for k in range(N)]
P = [list(map(int, input().split())) for k in range(N)]
B = [(((bin(k))[2:])+"000000000")[:10] for k in range(1,1024)]
ans = -10**9

for d in B:
    t = 0
    E = [0 for k in range(N)]
    for l in range(N):
        for k in range(10):
            E[l] += int(d[k])*F[l][k]
    for k in range(N):
        t += P[k][E[k]]
    ans = max(t,ans)

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
F = [list(map(int, input().split())) for k in range(N)]
P = [list(map(int, input().split())) for k in range(N)]
B = [(bin(k))[2:] for k in range(1,1024)]
ans = -10**9

for d in B:
    t = 0
    E = [0 for k in range(N)]
    for l in range(N):
        for k in range(len(d)):
            E[l] += int(d[k])*F[l][k]
    for k in range(N):
        t += P[k][E[k]]
    ans = max(t,ans)
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

F,P,b,T = [],[],1,-9999999999

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

while b < 1 << 10:
    bs = "{0:10b}".format(b)
    bsi = 0
    S = [0]*N
    for c in bs:
        if c == "1":
            for i in range(N):
                S[i] += F[i][bsi]
        bsi += 1
    t = 0
    for i in range(N):
        t += P[i][S[i]]
    if T < t:
        print("T",T,"t",t)
        T = t
    b += 1
print(T)

Submission status: Wrong Answer

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

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

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


print(ans())

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

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


def main():
    N = int(input())
    F = [list(map(int, input().split())) for i in range(N)]
    P = [list(map(int, input().split())) for i in range(N)]
    mp = 0
    fc = [sum(f) for f in F]
    r = []
    diff = [p[0] - p[1] for p in P]
    flag = 0
    for i, p in enumerate(P):
        m = max(p[:fc[i] + 1])
        if p[0] <= m:
            flag = 1
        r.append(m)

    if flag == 0:
        mini = min(diff)
        ind = diff.index(mini)
        r[ind] = p[1]

    return print(sum(r))


ans()

Submission status: Wrong Answer

Solution code:
N=int(input())
H=['']*N
W=['']*N
x=[]
for i in range(N):
    H[i]=list(map(int,input().split()))
for j in range(N):
    W[j]=list(map(int,input().split()))
for k in range(1,1024):
    t=[]
    for ii in range(10):
        if k&(1<<ii):
            t+=[1]
        else:
            t+=[0]
            ans=0
    for jj in range(N):
        s=0
        for kk in range(10):
            s+=H[jj][kk]*t[kk]
        ans+=W[jj][s]
    x.append(ans)
print(max(x))

Submission status: Wrong Answer

Solution code:
N=int(input())
H=['']*N
W=['']*N
x=[]
for i in range(N):
    H[i]=list(map(int,input().split()))
for j in range(N):
    W[j]=list(map(int,input().split()))
for k in range(1024):
    t=[]
    for ii in range(10):
        if k&(1<<ii):
            t+=[1]
        else:
            t+=[0]
            ans=0
    for jj in range(N):
        s=0
        for kk in range(10):
            s+=H[jj][kk]*t[kk]
        ans+=W[jj][s]
    x.append(ans)
print(max(x))

Submission status: Wrong Answer

Solution code:

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

result = -100000000

# opening schedule for my shop.
# start from 1(only open Mon.AM) to 1023(open all day)
for b in range(1, 1<<10):

    profit = 0
    # compare with other shops
    for i in range(n):

        common_opening = 0
        # compare time
        for j in range(10):

            if 1&(b>>j) and f[i][j] == 1:
            
                common_opening += 1
        profit += p[i][common_opening]

    result = max(result, profit)

print(result)

Submission status: Wrong Answer

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

result = -100000000

# opening schedule for my shop.
# start from 1(only open Mon.AM) to 1023(open all day)
for b in range(1, 1<<10):

    profit = 0
    # compare with other shops
    for i in range(n):

        common_opening = 0
        # compare time
        for j in range(10):

            if (b>>j)&1 and f[i][j] == 1:
                common_opening += 1
        profit += p[i][common_opening]

    result = max(result, profit)

print(result)

Submission status: Wrong Answer

Solution code:

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

result = -100000000

# opening schedule for my shop.
# start from 1(only open Mon.AM) to 1023(open all day)
for b in range(1, 1<<10):

    profit = 0
    # compare with other shops
    for i in range(n):

        common_opening = 0
        # compare time
        for j in range(10):

            if b>>j&1 and f[i][j]:
                common_opening += 1
        profit += p[i][common_opening]

    if result < profit:
        result = profit

print(result)

Submission status: Wrong Answer

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

result = -10000000

# opening schedule for my shop.
# start from 1(only open Mon.AM) to 1023(open all day)
for b in range(1, 1<<10):

    profit = 0
    # compare with other shops
    for i in range(n):

        common_opening = 0
        # compare time
        for j in range(10):

            if b>>j&1 and f[i][j]:
                common_opening += 1
        profit += p[i][common_opening]

    if result < profit:
        result = profit

print(result)

Submission status: Wrong Answer

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

# AtCoder Beginner Contest
# Problem C

if __name__ == '__main__':
    shop_count = int(input())
    shop_working_table = [list(map(int, input().split())) for _ in range(shop_count)]
    working_days = [shop_working_table[i].count(1) for i in range(shop_count)]
    benefit_table = [list(map(int, input().split())) for _ in range(shop_count)]

    benefit_total = 0
    including_closed = [max(benefit_table[j][:working_days[j] + 1]) for j in range(shop_count)]
    open_only = [max(benefit_table[j][1:working_days[j] + 1]) for j in range(shop_count)]

    for k in range(shop_count):
        if k == open_only.index(max(open_only)):
            benefit_total += max(open_only)
        else:
            benefit_total += max(including_closed[k], open_only[k])

    print(benefit_total)

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())))
#ビット探索
count=2**10
both=[0]*n
ans=-1000000000
profit=0
num=0#同時に出店した数を数える
for i in range(1023):
    count+=1
    bit=bin(count)
    for j in range(n):
        for k in range(10):
            if int(bit[k+3])&F[j][k]:#初め３桁は0b1が入っているので４桁目から
                num+=1
        profit+=P[j][num]   
        num=0           
    if profit>ans:
        print(profit)
        print(count)
        ans=profit
    profit=0
print(ans)

Submission status: Wrong Answer

Solution code:
import itertools
n = int(input())
f = []
p = []
res = -10**7
for i in range(n):
    f.append(list(map(int,input().split())))
for i in range(n):
    p.append(list(map(int,input().split())))
l = [0,1]
q = list(itertools.product(l,repeat=10))
del q[0]
for i in q:
    r = 0
    for j in range(n):
        c = 0
        for k in range(10):
            if i[k] and f[j][k]:
                c += 1
        r += p[j][c]
    res = r if res<r else res
print(res)

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     = []
count = 0
point = []
PP = []

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

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

Submission status: 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     = []
count = 0
point = []
PP = []

for _ in range(1024,2048):
    a.append(list(map(int,list(bin(_)[3:]))))
    
for k in range(1024):
    for i in range(n):
        for j in range(10):
            if f[i][j] == a[k][j]:
                count += 1
        point.append(p[i][count])
        count = 0
    PP.append(sum(point))
    point = []
print (max(PP))

Submission status: Wrong Answer

Solution code:
n=int(input())
f=[[[0for i in range(2)]for j in range(5)]for k in range(n)]
p=[[0for i in range(11)]for j in range(n)]
opn=[[0for i in range(2)]for j in range(5)]
maxi=-10000000
for i in range(n):
  l=list(map(int,input().split()))
  for j in range(5):
    f[i][j][0]=l[j*2]
    f[i][j][1]=l[j*2+1]
for i in range(n):
  p[i]=list(map(int,input().split()))
for i in range(1,2**10):
  s=bin(i)[2:].zfill(10)
  for j in range(10):opn[j//2][j%2]=int(s[j])
  ben=0
  for j in range(n):
    same=0
    for k in range(10):
      same+=opn[k//2][k%2]*f[j][k//2][k%2]
    ben+=p[j][same]
  maxi=max([maxi,ben])
print(maxi)

Submission status: Wrong Answer

Solution code:
import numpy as np
l = 10
f = 2 ** l - 1
ans = -float("inf")
n = int(input())
j = np.array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0] for j in range(n)])
for i in range(n):
    j[i] = (np.array(list(map(int, input().split()))))
costs = np.array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] for j in range(n)])
for i in range(n):
    costs[i] = (np.array(list(map(int, input().split()))))
for i in range(2**l):
    ff = np.array(list(map(int, list(format(f, "b").zfill(l)))))
    tmp = 0
    for h in range(n):
        tmp += costs[0][np.sum(ff == j[h])]
    ans = max(ans, tmp)
    f -= 1
print(ans-1)

Submission status: Wrong Answer

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

import sys

n = int(raw_input().split()[0])
a1 = [int(i) for i in raw_input().split()]
a2 = [int(i) for i in raw_input().split()]

maxS = 0
for i in range(1, n + 2):
    s = sum(a1[:i]) + sum(a2[i - 1:])
    # print i, a1[:i], a2[i - 1:],
    if s > maxS:
        # print '!!',
        maxS = s
    # print
    
sys.stdout.write('%d\n' % maxS)
sys.stdout.flush()

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

cost = -10**8
for a in itertools.product((0, 1), repeat=10):
    if a==(0, 0, 0, 0, 0, 0, 0, 0, 0, 0):
        continue
    tmp_cost = 0
    for i in range(N):
        tmp_c = 0
        l = 0
        for j in range(5):
            for k in range(2):
                tmp_c += F[i][l]*a[l]
                l += 1
        tmp_cost += P[i][tmp_c]
    cost = max(cost, tmp_cost)

print(cost)

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

cost = -10**8
for a in itertools.product((0, 1), repeat=10):
    if a==(0, 0, 0, 0, 0, 0, 0, 0, 0, 0):
        continue
    tmp_cost = 0
    c = [0 for _ in range(N)]
    for i in range(N):
        l = 0
        for j in range(5):
            for k in range(2):
                c[i] += F[i][l]*a[l]
                l += 1
        tmp_cost += P[i][c[i]]
    cost = max(cost, tmp_cost)

print(cost)

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

cost = -10**7
for a in itertools.product((0, 1), repeat=10):
    if a==(0, 0, 0, 0, 0, 0, 0, 0, 0, 0):
        continue
    tmp_cost = 0
    c = [0 for _ in range(N)]
    for i in range(N):
        l = 0
        for j in range(5):
            for k in range(2):
                c[i] += F[i][l]*a[l]
                l += 1
        tmp_cost += P[i][c[i]]
    cost = max(cost, tmp_cost)

print(cost)

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

cost = -10**7
for a in itertools.product((0, 1), repeat=10):
    if (0, 0, 0, 0, 0, 0, 0, 0, 0, 0)==a:
        continue
    tmp_cost = 0
    c = [0 for _ in range(N)]
    for i in range(N):
        l = 0
        for j in range(5):
            for k in range(2):
                c[i] += F[i][l]*a[l]
                l += 1
        tmp_cost += P[i][c[i]]
    if cost < tmp_cost:
        tmp_a = a
    cost = max(cost, tmp_cost)

print(cost)

Submission status: Wrong Answer

Solution code:
N=int(input())
F=[]
P=[]
ff=0
while ff < N:
    f=list(map(int,input().split(' ')))
    F.append(f)
    ff += 1
pp=0
while pp < N:
    p=list(map(int,input().split(' ')))
    P.append(p)
    pp += 1
def plus1(test,j):
    if test[j]==0:
        test[j]=1
    else:
        test[j]=0
        plus1(test,j+1)
test=[0,0,0,0,0,0,0,0,0,0]
k=0
Ans=-1e+8
while k<1023:
    plus1(test,0)
    i=0
    ev=0
    while i < N:
        l=0
        for q in range(0,10):
            if F[i][q]==1 and test[q]==1:
                l+=1
        ev += P[i][l]
        i+=1
    if Ans < ev:
        Ans=ev
    k+=1
print(Ans)

Submission status: Wrong Answer

Solution code:

def profit(xs, n, F, P):
    return sum([P[i][sum(map(lambda x: x[0]*x[1], zip(xs, F[i])))] for i in range(n)])


def vector(k):
    return [1 if k & 1 << i else 0 for i in range(10)]


def foo(n, F, P):
    return max([profit(vector(i), n, F, P) for pat in range(1, 1024)])


if __name__ == "__main__":
    n = int(input())
    F = {}
    P = {}
    for i in range(n):
        F[i] = list(map(int, input().split()))
    for i in range(n):
        P[i] = list(map(int, input().split()))
        
    print(foo(n, F, P))

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)

C=[0]*N
for i in range(N):
    for j in range(10):
        if F[i][j]==1:
            C[i]+=1

t=0
T=[]

for i in range(N):
    A=int(max(P[i][0:C[i]+1]))
    T.append(A)
    if A==P[i][0]:
        t+=1


S=[]
if t==N:
    for i in range(N):
        S.append(P[i][1])
    T.append(max(S))

print(sum(T))

Submission status: Wrong Answer

Solution code:
import math
import numpy as np
from operator import mul

# 整数Nを桁ごとのリストにする
# l = [int(x) for x in list(str(N))]

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)]
c = list(range(N))
max_p = -10**7-1

for i in range(1,2**10):
    i_bin = format(i, 'b').zfill(10)
    i_list = [int(x) for x in list(str(i_bin))]
    profit = 0 #それぞれの場合の利益を総当り
    for j in range(N):
        # 店jと同時に開いている時間の数を計算
        combine = map(mul, f[j], i_list)
        c[j] = sum(combine) # 0 <= c[j] <= 10
        profit += p[j][c[j]]
    if profit > max_p:
        max_p = profit
        i_max = i_list
        i_m = i

print(max_p)

Submission status: Wrong Answer

Solution code:
import math
import numpy as np
from operator import mul

# 整数Nを桁ごとのリストにする
# l = [int(x) for x in list(str(N))]

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)]
c = list(range(N))

for i in range(1,2^10):
    i_bin = format(i, 'b')
    i_list = [int(x) for x in list(str(i_bin))]
    profit = 0 #それぞれの場合の利益を総当り
    max_p = -10^7-1
    for j in range(N):
        # 店jと同時に開いている時間の数を計算
        combine = map(mul, f[j], i_list)
        c[j] = sum(combine)
        profit += p[j][c[j]]
    if profit > max_p:
        max_p = profit
print(max_p)

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)

C=[0]*N
for i in range(N):
    for j in range(10):
        if F[i][j]==1:
            C[i]+=1

t=0
T=[-(10**7)]*N
for i in range(N):
    for j in range(C[i]+1):
        if P[i][C[i]-j] > T[i]:
            T[i] = P[i][C[i]-j]
            if j==C[i]:
                t+=1

S=[]
if t==N:
    T.append(0)
    for i in range(N):
        S.append(P[i][1])
    S.append(-(10**7))
    for i in range(N):
        if S[i] > S[i+1]:
            T[N]=S[i]

print(sum(T))

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)

C=[0]*N
for i in range(10):
    for j in range(N):
        if F[j][i]==1:
            C[j]+=1

t=0
T=[-(10**7)]*N
for i in range(N):
    for j in range(C[i]+1):
        if P[i][C[i]-j] > T[i]:
            T[i] = P[i][C[i]-j]
            if j==C[i]:
                t+=1

S=[]
if t==N:
    for i in range(N):
        S.append(P[i][1])
    T.append(max(S))

print(sum(T))

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())
f = np.zeros((n, 10), dtype=np.int64)
p = np.zeros((n, 11), dtype=np.int64)

for i in range(n):
  tmp = list(map(int, input().split()))
  for j in range(10):
      f[i][j] = tmp[j]
for i in range(n):
  tmp = list(map(int, input().split()))
  for j in range(11):
    p[i][j] = tmp[j]

r = -1e9
for b in range(1, 1<<10):
  s = 0
  for i in range(n):
    c = 0
    for j in range(10):
      if (b >> j) & 1 == 1 and f[i][j]:
        c += 1
    s += p[i][c]
  if r < s:
    r = s

print(r)

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())
f = np.zeros((n, 10), dtype=np.int64)
p = np.zeros((n, 11), dtype=np.int64)

for i in range(n):
  tmp = list(map(int, input().split()))
  for j in range(10):
      f[i][j] = tmp[j]
for i in range(n):
  tmp = list(map(int, input().split()))
  for j in range(11):
    p[i][j] = tmp[j]

r = 0
for b in range(1, 1<<10):
  s = 0
  for i in range(n):
    c = 0
    for j in range(10):
      if (b >> j) & 1 == 1 and f[i][j]:
        c += 1
    s += p[i][c]
  if r < s:
    r = s

print(r)

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

for i in range(1,1 << 10):
  res=0
  for n in range(N):
    count=0
    for j in range(10):
      if i & F[n][j] << j: count+=1
    res+=P[n][count]
  ans=max(res,ans)
print(ans)

Submission status: Wrong Answer

Solution code:

def binarize(txt):
    xs = txt.split(' ')
    xs = [int(x) for x in xs]
    b = 0
    for i in range(10):
        b += xs[i] * (2 ** i)
    return b


def count1(b):
    b = b[2:]
    count = 0
    for i in range(len(b)):
        if b[i] == '1':
            count += 1
    return count


N = input()
N = int(N)

F = [0 for i in range(N)]

for i in range(N):
    txt = input()
    F[i] = binarize(txt)


P = [[] for i in range(N)]

for i in range(N):
    xs = input().split(' ')
    P[i] = [int(x) for x in xs]


m = - 10 ** 11

for i in range(1, 2**10-1):

    score = 0

    for j in range(N):
        b = bin(i & F[j])
        count = count1(b)
        score += P[j][count]

    if score > m:
        m = score

print(m)

Submission status: Wrong Answer

Solution code:
n = int(input())
f = [[int(x) for x in input().split()] for i in range(n)]
p = [[int(x) for x in input().split()] for i in range(n)]
ans=-(10**8)
for i in range(1,2**10):
  d, t, b={j:0 for j in range(n)}, 0, format(i, "010b")
  for j in range(n):
    for k in range(10):
      if (i>>k)%2&f[j][k]==1: d[j]+=1
    t+=p[j][d[j]]
  if ans<t: ans=t
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
f = [[int(x) for x in input().split()] for i in range(n)]
p = [input().split() for i in range(n)]
for i in range(n):
  p[i] = [int(x) for x in p[i]]
ans=min((min(x) for x in p))
b=format(i, "010b")
for i in range(1,2**10):
  d, t={j:0 for j in range(n)},0
  for j in range(n):
    for k in range(10):
      if (i>>k)%2*f[j][k]==1: d[j]+=1
    t+=p[j][d[j]]
  if ans<t: ans=t
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
f = [[int(x) for x in input().split()] for i in range(n)]
p = [input().split() for i in range(n)]
for i in range(n):
  p[i] = [int(x) for x in p[i]]
ans=p[0][1]
b=format(i, "010b")
for i in range(1,2**10):
  d, t={j:0 for j in range(n)},0
  for j in range(n):
    for k in range(10):
      if (i>>k)%2*f[j][k]==1: d[j]+=1
    t+=p[j][d[j]]
  if ans<t: ans=t
print(ans)