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 = []
for i in range(N):
    F.append(list(map(int, input().split())))
#print(F)

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

price = []
for i in range(N):
    time = sum(F[i])
    price.append(max(P[i][1:time+1]))

print(sum(price))

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**7

for i in range(1, 2**10):
    x = 0
    for n in range(N):
        c = 0
        for j in range(10):
            if (i >> j) & F[n][j]:
                c += 1
        x += P[n][c]
    ans = max(ans, x)

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
Fs = [len(input().replace("0", "").split()) for _ in range(N)]
Ps = []
for _ in range(N):
    temp = list(map(int, input().split()))
    temp += [0]
    Ps += [temp[:Fs[_]+1]]

rest_max_diff = -float('inf')
zeros = False
max_index = 0
max_sums = 0

for P in Ps:
    m = -float('inf')
    for index, p in enumerate(P):
        if (rest_max_diff < p-P[0] and index != 0):
            rest_max_diff = p-P[0]
        if (m >= p): continue
        m = p
        max_index = index
    if (max_index != 0):
        zeros = True
    max_sums += m

if not (zeros):
    ans = max_sums+rest_max_diff
else:
    ans = max_sums
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
Fs = [len(input().replace("0", "").split()) for _ in range(N)]
Ps = []
for _ in range(N):
    temp = list(map(int, input().split()))
    temp += [0]
    Ps += [temp[:Fs[_]+1]]

rest_max_diff = float('inf')
zeros = False
max_index = 0
max_sums = 0

for P in Ps:
    m = -float('inf')
    for index, p in enumerate(P):
        if (rest_max_diff > p-P[0] and index != 0):
            rest_max_diff = p-P[0]
        if (m >= p): continue
        m = p
        max_index = index
    if (max_index != 0):
        zeros = True
    max_sums += m

if not (zeros):
    ans = max_sums+rest_max_diff
else:
    ans = max_sums
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
Fs = [len(input().replace("0", "").split()) for _ in range(N)]
Ps = []
for _ in range(N):
    temp = list(map(int, input().split()))
    temp += [0]
    Ps += [temp[:Fs[_]+1]]

rest_max = -float('inf')
zeros = False
max_index = 0
max_sums = 0

for P in Ps:
    m = -float('inf')
    for index, p in enumerate(P):
        if (rest_max < p and index != 0):
            rest_max = p
        if (m >= p): continue
        m = p
        max_index = index
    if (max_index != 0):
        zeros = True
    max_sums += m

if not (zeros):
    ans = rest_max
else:
    ans = max_sums
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
Fs = [len(input().replace("0", "").split()) for _ in range(N)]
Ps = []
for _ in range(N):
    Ps += [list(map(int, input().split()))[:Fs[_]+1]]

rest_max = -float('inf')
zeros = False
max_index = 0
max_sums = 0

for P in Ps:
    m = -float('inf')
    for index, p in enumerate(P):
        if (rest_max < p and index != 0):
            rest_max = p
        if (m >= p): continue
        m = p
        max_index = index
    if (max_index != 0):
        zeros = True
    max_sums += m

if not (zeros):
    ans = rest_max
else:
    ans = max_sums
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
FF = [list(map(int, input().split())) for _ in range(N)]
PP = [list(map(int, input().split())) for _ in range(N)]

from itertools import combinations

mm = None
for i in range(1, 11):
  for ss in combinations(range(0, 10), i):
    m = 0
    for j in range(N):
      c = sum(f for k, f in enumerate(FF[j]) if k in ss)
      m += PP[j][c]
      if mm is None:
        mm = m
      else:
        mm = max(mm, m)
print(mm)

Submission status: Wrong Answer

Solution code:
n=int(input())
f=[list(map(int,input().split())) for i in range(n)]
p=[list(map(int,input().split())) for i in range(n)]
ans=-10**9
for i in range(1,2**10):
  a=0
  m=[i%2,i//2%2,i//4%2,i//8%2,i//16%2,i//32%2,i//64%2,i//128%2,i//256%2,i//512%2]
  mm=[0 for i in range(n)]
  for i in range(10):
    for j in range(n):
      if m[i]==f[j][i]:
        mm[j]+=1
  for i in range(n):
    a+=p[i][mm[i]]
  ans=max(ans,a)
print(ans)

Submission status: Wrong Answer

Solution code:
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = s_inpl()   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = inpl()	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import math
import copy
from collections import defaultdict, Counter
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
from bisect import bisect_left, bisect_right
import numpy as np

def i_inpl(): return int(input())
def s_inpl(): return map(int,input().split())
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")

N = i_inpl()
F = []
for _ in range(N):
    Fi = l_inpl()
    F.append(Fi)

P = []
for _ in range(N):
    Pi = l_inpl()
    P.append(Pi)


# bit全探索
ans = -1 * INF
for i in range(1, 2<<10):
    tmp = 0
    for j in range(N):
        c = 0
        # NOTE: iとF[j]のAND演算
        for k in range(10):
            if ((i>>k) & 1) & F[j][k]:
                c += 1
        tmp += P[j][c]
    ans = max(ans, tmp)

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())

bits = []
for i in range(n):
  bit = int(input().replace(" ", ""), 2)
  bits.append(bit)
p = [[int(item) for item in input().split()] for _ in range(n)]

ans = - 10**9
for i in range(1,2**10):
  val = 0
  for j,mise in enumerate(p):
    val += mise[bin(i & bits[j]).count("1")]
    print(bin(i & bits[j]))
  ans = max(ans, val)
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
f = [input().split(' ') for _ in range(n)]
p = [input().split(' ') for _ in range(n)]
res = -10**8
for num in range(1, 1024):
  tmp = 0
  for index in range(0, n):
    tmp += int(p[index][len([True for x in range(0, 10) if f[index][x]=='{:010b}'.format(num)[x]=='1'])])
  res = max(tmp, res)
print(res)

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())
f = np.array([list(map(int, input().split())) for i in range(n)])
p = np.array([list(map(int, input().split())) for i in range(n)])

ans = -99999999

openptn=np.array([[int(s) for s in list('{0:010b}'.format(i))] for i in range(1,2**10)])

for i in range(2**10 - 1):
	subans = 0
	for j in range(n):
		count = sum(f[j]*openptn[i])
		subans +=p[j][count]
		count = 0
		
		#print(subans)
	ans = max(ans, subans)

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())
f = np.array([list(map(int, input().split())) for i in range(n)])
p = np.array([list(map(int, input().split())) for i in range(n)])

ans = -99999999

openptn=np.array([[int(s) for s in list('{0:010b}'.format(i))] for i in range(1,2**10)])

for i in range(2**10 - 1):
	subans = 0
	for j in range(n):
		count = sum(f[j]*openptn[i])
		subans +=p[j][count]
		#print(subans)
	ans = max(ans, subans)

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())
f = np.array([list(map(int, input().split())) for i in range(n)])
p = np.array([list(map(int, input().split())) for i in range(n)])

ans = -99

openptn=np.array([[int(s) for s in list('{0:010b}'.format(i))] for i in range(1,2**10)])

for i in range(2**10 - 1):
	subans = 0
	for j in range(n):
		count = sum(f[j]*openptn[i])
		subans +=p[j][count-1]
		#print(subans)
	ans = max(ans, subans)

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())
f = np.array([list(map(int, input().split())) for i in range(n)])
p = np.array([list(map(int, input().split())) for i in range(n)])

ans = -99

openptn=np.array([[int(s) for s in list('{0:010b}'.format(i))] for i in range(1,2**10)])

for i in range(2**10 - 1):
	subans = 0
	for j in range(n):
		count = sum(f[j]*openptn[i])
		subans +=p[j][count]
		#print(subans)
	ans = max(ans, subans)

print(ans)

Submission status: Wrong Answer

Solution code:
import itertools
n = int(input())
p,f = [],[]

for i in range(n):
    f.append(list(map(int,input().split())))
for i in range(n):
    p.append(list(map(int,input().split())))

a = [0,1]
ans = 0
for v in itertools.product(a,repeat = 10):
    if sum(v) != 0:
        s = []
        for a in range(n):
            k = 0
            for b in range(10):
                if f[a][b] == v[b] and v[b] == 1:
                    k += 1
            s.append(k)

        x = 0
        for a in range(n):
            x += p[a][s[a]]
        if x > ans:
            #print(v,s,x)
            ans = x

print(ans)

Submission status: Wrong Answer

Solution code:
from itertools import product

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

ans = []
for p in product([0,1],repeat = 10):
	if sum(p) == 0:
		continue
	res = 0
	for i in range(n):
		cnt = 0
		for j in range(10):
			if p[j] == 1:
				cnt += F[i][j]
				res += P[i][cnt]
	ans.append(res)
print(max(ans))

Submission status: Wrong Answer

Solution code:
n=int(input())
F=[sum(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(n):
  ans+=max(P[i][:F[i]+1])
if ans==0:
  for i in range(n):
    tmp=P[i][:F[i]+1]
    ans=max(tmp)
    if ans ==0:
      ans=max(ans,sorted(tmp)[-2])
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
F=[sum(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(n):
  ans+=max(P[i][:F[i]+1])
if ans==0:
  for i in range(n):
    tmp=P[i][:F[i]+1]
    ans=max(tmp)
    if ans ==0:
      ans=sorted(tmp)[-2]
print(ans)

Submission status: Wrong Answer

Solution code:
MAX_TIME = 10

N = int(input())

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

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


def main():
    ans = -11000000001

    # 営業時間帯 最低でも ひとつの時間帯
    # 選択パターン
    for i in range(1, 2 ** MAX_TIME - 1):
        tmp = 0

        # 他の店
        for j in range(N):
            # 各時間帯
            cnt = sum([F[j][k] for k in range(MAX_TIME) if i >> k & 1])
            tmp += P[j][cnt]

        ans = max(ans, tmp)

    print(ans)
    return


main()

Submission status: Wrong Answer

Solution code:
# encoding:utf-8
import copy
import numpy as np
import random

n = int(input())
F = []
for i in range(n):
    f = [int(i) for i in input().split()]
    F.append(f)



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

F = np.array(F)
P = np.array(P)


def cal_val(shop_num,open_time):
    open_time = int(np.dot(F[shop_num],open_time.T))
    # print(open_time)
    return P[shop_num,open_time]

def to2digit(i):
    open_time = np.zeros([10])
    for count in range(10):
        if i%2==1:
            open_time[count] = 1
        i = i//2
    return open_time



values = []

for i in range(1,2**10-1):
    open_time = np.zeros([10])
    for j in range(10):
        if i%2==1:
            open_time[j] = 1
        i = i//2
    value = 0
    for shop_num in range(n):
        value += cal_val(shop_num,open_time)
    values.append(value)

print(max(values))

Submission status: Wrong Answer

Solution code:
# encoding:utf-8
import copy
import numpy as np
import random

n = int(input())
F = []
for i in range(n):
    f = [int(i) for i in input().split()]
    F.append(f)



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

F = np.array(F)
P = np.array(P)


def cal_val(shop_num,open_time):
    open_time = int(np.dot(F[shop_num],open_time.T))
    # print(open_time)
    return P[shop_num,open_time]

def to2digit(i):
    open_time = np.zeros([10])
    count = 0
    while(i>0):
        if i%2==1:
            open_time[count] = 1
        i = i//2
        count += 1
    return open_time



values = []

for i in range(1,2**10-1):
    open_time = np.zeros([10])
    for j in range(10):
        if i%2==1:
            open_time[j] = 1
        i = i//2
        
    value = 0
    for shop_num in range(n):
        value += cal_val(shop_num,open_time)
    values.append(value)

print(max(values))

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc080/tasks/abc080_c

import itertools
import collections
import bisect


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

    # print(F)
    # print(P)

    # big value
    INF = int(1e15)
    ans = -INF
    pattern = 1024  # 1 をパターンの数だけ左にシフトする
    for i in range(3, pattern):
        score = 0
        # print(bin(i))
        for s in range(N):
            matched = 0
            f = F[s]
            p = P[s]
            # print(f)
            # print(p)
            for j in range(10):
                if (i >> j) & 1:  # open
                    matched += 1 if f[j] else 0

            # print("s = {} match = {}".format(s, matched))
            score += p[matched]
        # print(score)
        ans = max(ans, score)

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
F = [list(map(int, input().strip().split())) for i in range(N)]
P = [list(map(int, input().strip().split())) for i in range(N)]
maxProfit = 0



for i in range(1,1024):
    openTime = list(map(int, list("{:0>10}".format(bin(i)[2:]))))
    thisProfit = 0
    for n in range(N):
        shopOpneTime = F[n]
        shopProfit = P[n]
        counter = 0
        for j in range(10):
            if((shopOpneTime[j])and(openTime[j])):
                 counter += 1
        thisProfit += shopProfit[counter]
    maxProfit = max(thisProfit, maxProfit)

print(maxProfit)

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)]
x = - 10 ** 8
for a in product((0, 1), repeat=10):
    if not any(a):
        continue
    num = 0
    for f, p in zip(F, P):
        c = sum(map(lambda z: z[0] * z[1], zip(a, f)))
        num += p[c]
    x = max(x, num)
print(x)

Submission status: Wrong Answer

Solution code:
def calculate():
    global maxv
    if sum(ans) == 0:
        return
    score = 0
    for f, p in zip(F, P):
        score += p[bin(int(''.join(map(str, ans)), 2)&f).count('1')]
    maxv = max(maxv, score)

def dfs(pos):
    if pos == 10:
        calculate()
        return
    ans[pos] = 0
    dfs(pos+1)
    ans[pos] = 1
    dfs(pos+1)

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

pos = 0
ans = [0] * 10
maxv = -1000000
dfs(pos)
print(maxv)

Submission status: Wrong Answer

Solution code:
def calculate():
    global maxv
    if sum(ans) == 0:
        return
    score = 0
    for i in range(N):
        num = 0
        for j in range(10):
            if ans[j] == 0:
                continue
            num = num + [0, 1][ans[j] == F[i][j]]
        score += P[i][num]
    maxv = max(maxv, score)

def dfs(pos):
    if pos == 10:
        calculate()
        return
    ans[pos] = 0
    dfs(pos+1)
    ans[pos] = 1
    dfs(pos+1)

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

pos = 0
ans = [0] * 10
maxv = -1000000
dfs(pos)
print(maxv)

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

c = [[P[i][j] for j in range(sum(f_)+1)][1:] for i, f_ in enumerate(F)]
maxv = max(-1000000, max(c[0]))

for p_ in c[1:]:
    tmp = max(p_)
    if tmp < 0 and maxv >= tmp:
        maxv = tmp
    else:
        maxv += tmp
print(maxv)

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 = -(1e9)
for i in range(1, 2**10):
  b = 0
  for f, p in zip(F, P):
    b += p[bin(f&i).count("1")]
  ans = max(ans, b)
print(ans)

Submission status: Wrong Answer

Solution code:
import itertools
import numpy as np
from collections import Counter
N = int(input())
F = np.array([list(map(int, input().split())) for _ in range(N)])
P = [list(map(int, input().split())) for _ in range(N)]
benefit = -10^(8)

for i in itertools.product((0, 1), repeat=10):
    if sum(i) != 0:
        C = np.array(list(i)) + F
        pre_benefit = 0
        for j in range(N):
            count = len(np.where(C[j]==2)[0])
            pre_benefit += P[j][count]
        if benefit < pre_benefit:
            benefit = pre_benefit
print(benefit)

Submission status: Wrong Answer

Solution code:
import numpy as np
from collections import Counter
N = int(input())
F = [list(map(int, input().split())) for _ in range(N)]
P = np.array([list(map(int, input().split())) for _ in range(N)])
benefit = 0
open = 0

for i in range(len(F)):
    count = F[i].count(1)
    m = -10^(8)
    for j in range(count+1):
        if m < P[i][j]:
            m = P[i][j]
            open += j
    benefit += m
if open == 0:
    benefit = max(P[:,1])
print(benefit)

Submission status: Wrong Answer

Solution code:
import numpy as np
from collections import Counter
N = int(input())
F = [list(map(int, input().split())) for _ in range(N)]
P = np.array([list(map(int, input().split())) for _ in range(N)])
benefit = 0
open = 0

for i in range(len(F)):
    count = F[i].count(1)
    m = -10000
    for j in range(count+1):
        if m < P[i][j]:
            m = P[i][j]
            open += j
    benefit += m
if open == 0:
    benefit = max(P[:,1])
print(benefit)

Submission status: Wrong Answer

Solution code:
from itertools import product


def BothAreOpen(arrange1, arrange2):
    counter = 0
    for element in zip(arrange1, arrange2):
        if element == (1, 1):
            counter += 1
    return counter


N = int(input())
OpeningHours = [list(map(int, input().split())) for i in range(N)]
Profits = [list(map(int, input().split())) for i in range(N)]

ans = -100000000

for MyShop in product([0, 1], repeat=10):
    if MyShop == tuple([0] * 10):
        continue

    chofuku = []
    for OtherStore in OpeningHours:
        chofuku.append(BothAreOpen(MyShop, OtherStore))

    x = sum([Profits[i][chofuku[i]] for i in range(N)])
    if x > ans:
        ans = x

print(ans)

Submission status: Wrong Answer

Solution code:
#from collections import Counter
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))
ans=-(1<<40)
for bit in range(1<<10):
    tmp = 0
    for i in range(N):
        c=0
        for j in range(10):
            if bit&(1<<j) and F[i][j]:
                c+=1
        tmp+=P[i][c]
    ans = max(ans,tmp)
print(ans)

Submission status: Wrong Answer

Solution code:
#from collections import Counter
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))
ans=-(1<<30)
for bit in range(1<<10):
    tmp = 0
    for i in range(N):
        c=0
        for j in range(10):
            if bit&(1<<j) and F[i][j]:
                c+=1
        tmp+=P[i][c]
    ans = max(ans,tmp)
print(ans)

Submission status: Wrong Answer

Solution code:
MIN = -(10**7)-1

def solve():
    cnt = 0
    i = 0
    for lst in f_lst:
        chk_range = sum(lst)
        cnt += max(p_lst[i][1:chk_range+1])
        i += 1
    if cnt < 0:
        cnt = min(min(p_lst))
    return cnt


n = int(input())
f_lst = [[] for _ in range(n)]
p_lst = [[] for _ in range(n)]
for i in range(n):
    f_lst[i].extend(map(int,input().split()))
for i in range(n):
    p_lst[i].extend(map(int,input().split()))

ans = solve()
print(ans)

Submission status: Wrong Answer

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

ans = 0
for i in range(N):
    cnt = sum(F[i])
    if i > 0 and max(P[i][1 : cnt + 1]) < 0:
        ans += max(P[i][: cnt + 1])
    else:
        ans += max(P[i][1 : cnt + 1])
    
print(ans)

Submission status: Wrong Answer

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

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

# # パターンAとパターンBがどれだけ一致しているかを表す函数
def score(_bin, F, P):
    score = 0
    for j, f in enumerate(F):
        hit_counter = 0
        for i in range(10):
            if _bin>>i & 1 and f[i] == 1:
                hit_counter += 1
        score += P[j][hit_counter]
    return score

max_score = -1000
for i in range(1,1<<10):
    max_score = max(max_score, score(i, F, P))

print(max_score)

Submission status: Wrong Answer

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

#営業する時間を入力してそれぞれのお店との被る日数を出力
def count_number(shop):
    #一日もあかない日を明確にする
    if(sum(shop)==0):
        return(False)
    count = [0]*N
    for i in range(N):
        for j in range(10):
            if(shop[j]==1 and F[i][j]==1):
                count[i] = count[i]+1
    return (count)
#お店と被る日数を入力して利益を出力
def benefit(count):
    #一日も店を開かない日があってはダメなので利益を最小にしておく
    if(count==False):
        return(-100000000)
    bene_sum = 0
    for i in range(N):
        bene_sum = bene_sum + P[i][count[i]]
    return(bene_sum)

bene = []
for shop in itertools.product(range(2),repeat = 10):
    bene_next = benefit(count_number(shop))
    bene.append(bene_next)
print(max(bene))

Submission status: Wrong Answer

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

#営業する時間を入力してそれぞれのお店との被る日数を出力
def count_number(shop):
    count = [0]*N
    for i in range(N):
        for j in range(10):
            if(shop[j]==1 and F[i][j]==1):
                count[i] = count[i]+1
    return (count)
#お店と被る日数を入力して利益を出力
def benefit(count):
    #一日も店を開かない日があってはダメなので利益を最小にしておく
    if(sum(count)==0):
        return(-100000000)
    bene_sum = 0
    for i in range(N):
        bene_sum = bene_sum + P[i][count[i]]
    return(bene_sum)

bene = []
for shop in itertools.product(range(2),repeat = 10):
    bene_next = benefit(count_number(shop))
    bene.append(bene_next)
print(max(bene))

Submission status: Wrong Answer

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

#営業する時間を入力してそれぞれのお店との被る日数を出力
def count_number(shop):
    count = [0]*N
    for i in range(N):
        for j in range(10):
            if(shop[j]==1 and F[i][j]==1):
                count[i] = count[i]+1
    return (count)
#お店と被る日数を入力して利益を出力
def benefit(count):
    #一日も店を開かない日があってはダメなので利益を最小にしておく
    if(sum(count)==0):
        return(-100000000)
    bene_sum = 0
    for i in range(N):
        bene_sum = bene_sum + P[i][count[i]]
    return(bene_sum)

bene = []
for shop in itertools.product(range(2),repeat = 10):
    bene_next = benefit(count_number(shop))
    bene.append(bene_next)
max(bene)

Submission status: Wrong Answer

Solution code:
N=int(input())
F=[[0]*10 for _ in range(N)]
P=[[0]*11 for _ in range(N)]
for i in range(N):
    F[i]=list(map(int,input().split()))
for i in range(N):
    P[i]=list(map(int,input().split()))
i=1
ans=P[0][1]
cnt=0
while i<=int('1111111111',2):
    tmp_ans=0
    bin_str=format(i,'10b')
    for j in range(N):
        cnt=0
        for k in range(10):
            if bin_str[k]=='1' and F[j][k]==1:
                cnt+=1
        tmp_ans+=P[j][cnt]
    if tmp_ans>ans:
        ans=tmp_ans
    i+=1
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
F=[[0]*10 for _ in range(N)]
P=[[0]*10 for _ in range(N)]
for i in range(N):
    F[i]=list(map(int,input().split()))
for i in range(N):
    P[i]=list(map(int,input().split()))
i=1
ans=P[0][1]
cnt=0
while i<=int('1111111111',2):
    tmp_ans=0
    bin_str=format(i,'10b')
    for j in range(N):
        cnt=0
        for k in range(10):
            if bin_str[k]=='1' and F[j][k]==1:
                cnt+=1
        tmp_ans+=P[j][cnt]
    if tmp_ans>ans:
        ans=tmp_ans
    i+=1
print(ans)

Submission status: Wrong Answer

Solution code:
I=input;n=int(I());f=[I()[::2]for _ in[0]*n];p=[I().split()for _ in[0]*n];print(max(sum(int(q[bin(i&int(g)).count('1')])for g,q in zip(f,p))for i in range(1,1024)))

Submission status: Wrong Answer

Solution code:
import itertools

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 = -100000000
for k in range(1,11):
  for j in itertools.combinations(range(10),k):
    tmp = 0
    for f,p in zip(F, P):
      num = sum([f[cnt] for cnt in j])
      tmp += p[num]
    ans = max(ans,tmp)
    
print(ans)

Submission status: Wrong Answer

Solution code:
import math
import numpy as np
import sys
input = sys.stdin.readline
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
F = [sum(IL()) for i in range(N)]
P = [IL() for i in range(N)]

f = 0
cnt = 0
ans = 0
mi_ans = int(-10e10)
for i in range(N):
	tmp = max(P[i][:F[i]+1])
	if tmp > 0:
		ans += tmp
		f = 1
	elif tmp == 0:
		l = [j for j in P[i][:F[i]+1] if j<0]
		l.sort()
		mi_ans = max(mi_ans,l[-1])
		cnt += 1
		f = 1
	else:
		mi_ans = max(mi_ans,tmp)

if f == 0 or cnt == N:
	print(mi_ans)
else:
	print(ans)

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())))
  
ma = 0

for i in range(1, 1024):
  t = i
  x = []
  for j in range(10):
    x.append(t % 2)
    t //= 2
  wa = 0
  for j in range(N):
    cnt = 0
    for k in range(10):
      if x[k] == 1 and F[j][k] == 1:
        cnt += 1
    wa += P[j][cnt]
    
  if ma < wa:
    ma = wa
print(ma)

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())))
  
ma = 0

for i in range(1, 1024):
  t = i
  x = []
  for j in range(10):
    x.append(t % 2)
    t //= 2
  wa = 0
  for j in range(N):
    cnt = 0
    for k in range(10):
      if x[k] == 0 and F[j][k] == 1:
        cnt += 1
    wa += P[j][cnt]
    
  if ma < wa:
    ma = wa
print(ma)

Submission status: Wrong Answer

Solution code:
n=int(input())
f=[list(map(str,input().split()))for i in range(n)]
p=[list(map(int,input().split()))for i in range(n)]
d=[]
for i in range(n):
    c=""
    for j in range(10):
        c+=f[i][j]
    else:
        d.append(int(c,2))
ans=float("-inf")
for i in range(1,1024):
    k=0
    for j in range(n):
        k+=p[j][bin(d[j]&i).count("1")] 
    else:
        if k>ans:
            print(i,k)
            ans=max(k,ans)
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
f=[list(map(str,input().split()))for i in range(n)]
p=[list(map(int,input().split()))for i in range(n)]
d=[]
for i in range(n):
    c=""
    for j in range(10):
        c+=f[i][j]
    else:
        d.append(int(c,2))
ans=float("-inf")
for i in range(1,1025):
    k=0
    for j in range(n):
        k+=p[j][bin(d[j]&i).count("1")] 
    else:
        ans=max(k,ans)
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
f=[list(map(str,input().split()))for i in range(n)]
p=[list(map(int,input().split()))for i in range(n)]
d=[]
for i in range(n):
    c=""
    for j in range(10):
        c+=f[i][j]
    else:
        d.append(int(c,2))
ans=-float("inf")
for i in range(1,1025):
    k=0
    for j in range(n):
        k+=p[j][bin(d[j]&i).count("1")] 
    else:
        ans=max(k,ans)
print(ans)