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 = [input().count("1") for i in range(n)]
p = [input().split()[:f[i]+1] for i in range(n)]
for i in range(n):
  p[i] = [int(x) for x in p[i]]
m=[max(l) for l in p]
d=[p[i].index(m[i]) for i in range(n)]
if sum(d)!=0:
  print(sum(m))
else:
  for i in range(n):
    p[i].pop(d[i])
    m=[max(l) for l in p]
  print(max(m))

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


profit = float("-inf")

for i in range(1,1024):
	tmp = 0
	tmp2 = 0
	for j in range(N):
		tmp = (bin(i & F[j]).count('1'))
		tmp2 = P[j][tmp]
	profit = max(profit, tmp2)

print(profit)

Submission status: Wrong Answer

Solution code:
N=int(input())
F=[int(input().replace(" ",""), 2) for i in range(N)]
P=[list(map(int,input().split())) for i in range(N)]
ans=-10**7
for i in range(1,1 << 10):
  res=0
  for n in range(N):
    res+=P[n][bin(i & F[n]).count("1")]
  ans=max(res,ans)
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
F=[list(map(int,input().split())) for i in range(N)]
P=[list(map(int,input().split())) for i in range(N)]
ans=-10**7
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:
n = int(input())
shop_i = []
for i in range(n):
    shop_i.append(list(map(int, input().split())))
gain_i = []
for i in range(n):
    gain_i.append(list(map(int, input().split())))

gain_max = -100000000
for i in range(2**10):
    if i ==0:
        pass
    else:        
        shop_sister = format(i, '010b')
        gain_now = []
        for shop in range(n):
            times = 0
            for n_cap in range(10):
                if shop_i[shop][n_cap] == 1 and shop_sister[n_cap] == '1':
                    times += 1
            gain_now.append(gain_i[shop][times]) 
        gain_now = sum(gain_now)
        if gain_now>gain_max:
            gain_max = gain_now

print(gain_max)

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
shop_i = []
for i in range(n):
    shop_i.append(np.array(list(map(int, input().split()))).astype(np.bool))
gain_i = []
for i in range(n):
    gain_i.append(np.array(list(map(int, input().split()))))

gain_max = -100000000
for i in range(2**10):
    if i ==0:
        pass
    else:        
        shop_sister = format(i, '010b')
        me = np.array([shop_sister[keta] for keta in range(10)]).astype(np.bool)
        gain_now = []
        for shop in range(n):
            togather = sum(me&shop_i[shop])
            gain_now.append(gain_i[shop][togather]) 
        gain_now = sum(gain_now)
        if gain_now>gain_max:
            gain_max = gain_now

print(gain_max)

Submission status: Wrong Answer

Solution code:
N = int(raw_input())
F = []
for n in range(N):
    F.append([int(val) for val in raw_input().split(" ")])
P = []
for n in range(N):
    P.append([int(val) for val in raw_input().split(" ")])

print N
print F
print P

max_val = None
for i_X in xrange(1, 2**10):
    c_i = [0]*N
    for i_pos in range(10):
        X_ijk = (i_X/(2**i_pos))%2
        for i_n in xrange(N):
            c_i[i_n] += F[i_n][i_pos] * X_ijk
    score = sum([P[i_n][c_i[i_n]] for i_n in xrange(N)])
    if (type(max_val) == type(None)) or (score > max_val):
        max_val = score

print max_val

Submission status: Wrong Answer

Solution code:
# coding :utf-8
N=int(input())

F=[]
P=[]

table = [2**i for i in range(10)]
print(table)

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

maxx=-1000000000001


for i in range(1,1024):
    total=0
    for j in range(N):
        n=0
        for k in range(10):
            n +=(1 if i&table[k] !=0 else 0)*F[j][k]
        total += P[j][n]
    if total >maxx:
        maxx= total
print(maxx)

Submission status: Wrong Answer

Solution code:
# coding :utf-8
N=int(input())

F=[]
P=[]

table = [2**i for i in range(10)]


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

maxx=-1000000000001
total=0

for i in range(1,1024):
    for j in range(N):
        for k in range(10):
            n=0
            n +=(1 if i&table[k] !=0 else 0)*F[j][k]
        total += P[j][n]
    if total >maxx:
        maxx= total
print(maxx)

Submission status: Wrong Answer

Solution code:
# coding :utf-8
N=int(input())

F=[]
P=[]

table = [2**i for i in range(10)]
print(table)

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

maxx=-1000000000001
total=0

for i in range(1,1024):
    for j in range(N):
        for k in range(10):
            n=0
            n +=(1 if i&table[k] !=0 else 0)*F[j][k]
        total += P[j][n]
    if total >maxx:
        maxx= total
print(maxx)

Submission status: Wrong Answer

Solution code:
N = int(raw_input())
lis = []
last = []
for num in xrange(N*2):
  lis.append( map(int,raw_input().split()) )
for a in xrange(2):
  for b in xrange(2):
    for c in xrange(2):
      for d in xrange(2):
        for e in xrange(2):
          for f in xrange(2):
            for g in xrange(2):
              for h in xrange(2):
                for i in xrange(2):
                  for j in xrange(2):
                    sumlis = []
                    for numb in xrange(N):
                      count = 0
                      for select in xrange(10):
                        check = [a,b,c,d,e,f,g,h,i,j]
                        if check == [0,0,0,0,0,0,0,0,0,0]:
                          continue
                        if check[select] == 1 and lis[numb][select] == 1:
                          count += 1
                      sumlis.append(lis[numb + N][count])
                    last.append(sum(sumlis))
print max(last)

Submission status: Wrong Answer

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

joisino = [False] * 10


def dfs(i):
    if i == 10:
        score = 0
        for j in range(N):
            G = [(joisino[k] and (F[j][k] == 1)) for k in range(10)]
            count = G.count(True)
            score += P[j][count]
        return score
    else:
        ans1 = dfs(i + 1) if joisino.count(True) > 0 else -float('inf')
        joisino[i] = True
        ans2 = dfs(i + 1)
        joisino[i] = False
        return max(ans1, ans2)


ans = max(-float('inf'), dfs(0))
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
f = []
p = []
s = [0 for i in range(10)]
for i in range(n):
    f.append(list(int(i) for i in input().split()))
for i in range(n):
    p.append(list(int(i) for i in input().split()))

def count(x):
    cunt = 0
    for i in range(len(openlist)):
        if f[x][9-i] == openlist[i]==1:
            cunt +=1
    return cunt
max1 = -10000000000000
for i in range(1,1024):
    sum = 0
    open = format(i,'b')
    openlist = [int(j) for j in open]
    for k in range(n):
        sum += p[k][count(k)]
    max1 = max(max1,sum)
print(max1)

Submission status: Wrong Answer

Solution code:
n = int(input())
f = []
p = []
s = [0 for i in range(10)]
for i in range(n):
    f.append(list(int(i) for i in input().split()))
for i in range(n):
    p.append(list(int(i) for i in input().split()))

def count(x):
    cunt = 0
    for i in range(len(openlist)):
        if f[x][i] == openlist[i]==1:
            cunt +=1
    return cunt
max1 = -10000000000000
for i in range(1,1024):
    sum = 0
    open = format(i,'b')
    openlist = [int(j) for j in open]
    for k in range(n):
        sum += p[k][count(k)]
    max1 = max(max1,sum)
print(max1)

Submission status: Wrong Answer

Solution code:
# coding: utf-8

for i in range(1,3):
    print(i)

N = int(input())

F = []
P = []

table = [2**i for i in range(10)]

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

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

maxx = -1000000001

for i in range(1, 1024):
    total = 0
    for j in range(N):
        n = 0
        for t in range(10):
            n += (1 if i&table[t] != 0 else 0)*F[j][t]
        total += P[j][n]
    if total > maxx:
        maxx = total

print(maxx)

Submission status: Wrong Answer

Solution code:
# coding: utf-8

N = int(input())

F = []
P = []

table = [2**i for i in range(10)]

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

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

maxx = -1000000001

for i in range(1, 1025):
    total = 0
    for j in range(N):
        n = 0
        for t in range(10):
            n += (1 if i&table[t] != 0 else 0)*F[j][t]
        total += P[j][n]
    if total > maxx:
        maxx = total

print(maxx)

Submission status: Wrong Answer

Solution code:
inp = input()
N = int(inp)

eigyo = []

b = []
Ci = []
for i in range(N):
    N_ = list(map(int, input().split()))
    eigyo.append(N_)
    Ci.append(sum(N_))

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


max_ = 0
rieki = 0

for i in range(len(eigyo)):
    buff = P[i][Ci[i]]
    if i==0:
        max_ = buff
    if buff > max_:
        max_ = buff
    

print(max_)

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
f = []
p = []
for i in range(n):
    f.append(list(map(int, input().split())))
for i in range(n):
    p.append(list(map(int, input().split())))

pattern = []
tmp = []
for i in range(n):
    tmp.append(f[i][0])
pattern.append(tmp)

for i in range(1, 10):
    tmp = []
    tmp_loop = pattern[:]
    for j in range( n):
        tmp.append(f[j][i])
    for pat in tmp_loop:
        pattern.append(list(np.array(pat)+np.array(tmp)))
    pattern.append(tmp)

ans = -1000000
for pat in pattern:
    a = 0
    for i in range(n):
        a += p[i][pat[i]]
    ans = max(ans, a)
print(ans)

Submission status: Wrong Answer

Solution code:

import copy

shop_num = int(input().rstrip())

# business hour
shop_data = {}
for i in range(shop_num):
	shop_data[i] = input().rstrip().split(' ')

# benefit
shop_benefit = {}
for i in range(shop_num):
	shop_benefit[i] = input().rstrip().split(' ')

patterns = [0, 1, 2];

targets = []
for pattern1 in patterns:
	list1 = []
	if pattern1 == 1:
		list1.append(0)
	elif pattern1 == 2:
		list1.append(1)
	else:
		list1.append(0)
		list1.append(1)

	for pattern2 in patterns:
		list2 = copy.deepcopy(list1)
		if pattern2 == 1:
			list2.append(2)
		elif pattern2 == 2:
			list2.append(3)
		else:
			list2.append(2)
			list2.append(3)
		for pattern3 in patterns:
			list3 = copy.deepcopy(list2)
			if pattern3 == 1:
				list3.append(4)
			elif pattern3 == 2:
				list3.append(5)
			else:
				list3.append(4)
				list3.append(5)
			for pattern4 in patterns:
				list4 = copy.deepcopy(list3)
				if pattern4 == 1:
					list4.append(6)
				elif pattern4 == 2:
					list4.append(7)
				else:
					list4.append(6)
					list4.append(7)
				for pattern5 in patterns:
					list5 = copy.deepcopy(list4)
					if pattern5 == 1:
						list5.append(8)
					elif pattern5 == 2:
						list5.append(9)
					else:
						list5.append(8)
						list5.append(9)

					targets.append(copy.deepcopy(list5))

ben_list = []
for target in targets:
	ben = 0
	for key in shop_data:
		count = 0
		for time in range(10):
			data = int(shop_data[key][time])
			if time in target:
				if data == 1:
					count += 1
			else:
				if data == 0:
					count += 1

		ben += int(shop_benefit[key][count])

	ben_list.append(ben)

print(max(ben_list))

Submission status: Wrong Answer

Solution code:
import itertools

def solve():
    N = int(input())
    F = []
    cnt_of_1 = []
    for _ in range(N):
        tmp_F = list(map(int, input().split(" ")))
        cnt_of_1.append(tmp_F.count(1))
        F.append(tmp_F)
    P = []
    zero_cmb = []
    for _ in range(N):
        tmp_P = list(map(int, input().split(" ")))
        zero_cmb.append(tmp_P[0])
        P.append(tmp_P)

    max_comb = []
    second_com = []
    cnt = 0
    for i in range(N):
        P[i] = P[i][:cnt_of_1[i] + 1]
        tmp_max = max(P[i])
        tmptmp = P[i].copy()
        tmptmp.sort()
        second_com.append(tmptmp[-2])
        if tmp_max == P[i][0]:
            cnt += 1
            max_comb.append(max(P[i][1:]))
        else:
            max_comb.append(tmp_max)

        # max_comb.append(max(P[i]))

    if cnt == N:
        aa = max(second_com)
        bb = second_com.index(aa)
        max_comb[bb] = aa


    """
    cmb = list(itertools.product(*P))
    target = cmb.index(tuple(zero_cmb))
    del cmb[target]
    maximum = -1000000000
    for ele in cmb:
        maximum = max(maximum, sum(ele))

    print(maximum)
    """
    max_comb.sort()
    max_comb.reverse()
    if max_comb[0] < 0:
        ans = max_comb[-1]
    else:
        ans = 0
        for ele in max_comb:
            if ele < 0:
                break
            else:
                ans += ele

    print(ans)
solve()

Submission status: Wrong Answer

Solution code:

import copy

shop_num = int(input().rstrip())

# business hour
shop_data = {}
for i in range(shop_num):
	shop_data[i] = input().rstrip().split(' ')

# benefit
shop_benefit = {}
for i in range(shop_num):
	shop_benefit[i] = input().rstrip().split(' ')

patterns = [0, 1, 2];

targets = []
for pattern1 in patterns:
	list1 = []
	if pattern1 == 1:
		list1.append(0)
	elif pattern1 == 2:
		list1.append(1)
	else:
		list1.append(0)
		list1.append(1)

	for pattern2 in patterns:
		list2 = copy.deepcopy(list1)
		if pattern2 == 1:
			list2.append(2)
		elif pattern2 == 2:
			list2.append(3)
		else:
			list2.append(2)
			list2.append(3)
		for pattern3 in patterns:
			list3 = copy.deepcopy(list2)
			if pattern3 == 1:
				list3.append(4)
			elif pattern3 == 2:
				list3.append(5)
			else:
				list3.append(4)
				list3.append(5)
			for pattern4 in patterns:
				list4 = copy.deepcopy(list3)
				if pattern4 == 1:
					list4.append(6)
				elif pattern4 == 2:
					list4.append(7)
				else:
					list4.append(6)
					list4.append(7)
				for pattern5 in patterns:
					list5 = copy.deepcopy(list4)
					if pattern5 == 1:
						list5.append(8)
					elif pattern5 == 2:
						list5.append(9)
					else:
						list5.append(8)
						list5.append(9)

					targets.append(copy.deepcopy(list5))

ben_list = []
for target in targets:
	ben = 0
	for key in shop_data:
		count = 0
		for time in range(10):
			data = int(shop_data[key][time])
			if time in target:
				if data == 1:
					count += 1
			else:
				if data == 0:
					count += 1

		ben += int(shop_benefit[key][count])

	ben_list.append(ben)

print(ben_list)
print(max(ben_list))

Submission status: Wrong Answer

Solution code:


inp = input()
N = int(inp)

eigyo = []

b = []
Ci = []
for i in range(N):
    N_ = list(map(int, input().split()))
    eigyo.append(N_)
    Ci.append(sum(N_))

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


max_ = 0
rieki = 0

for i in range(len(eigyo)):
    buff = P[i][Ci[i]]
    if buff > max_:
        max_ = buff

print(max_)

Submission status: Wrong Answer

Solution code:
N = int(input())

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import itertools
def to_bool(i):
    if i == '1':
        return True
    return False

# 整数の入力
n = int(input())
f = []
for i in range(n):
    f.append(list(to_bool(i) for i in input().split()))

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

print(f)
print(p)

result = -100
for eigyou in itertools.product((True,False), repeat=10):
    if sum(1 for a in zip(eigyou) if a) == 0:
        continue
    goukei = 0
    for i in range(n):
        goukei += p[i][sum(1 for a,b in zip(eigyou,f[i]) if a and b)]
    if result < goukei:
        result = goukei
    
print(result)

Submission status: Wrong Answer

Solution code:
import itertools
import numpy as np

N = int(input())
F = list()
P = list()
for i in range(N):
	f = list(map(int, input().split()))
	#F.append([f[0:2],f[2:4],f[4:6],f[6:8],f[8:10]])
	F.append(f)
for i in range(N):
	p = list(map(int, input().split()))
	P.append(p)

F = np.array(F)

count = [0] * N

n_range = []
for val in list(itertools.product([0,1], repeat=10)):
	indices = [i for i,j in enumerate(val) if j == 1]
	f = [sum(list(F[i][indices])) for i in range(N)]
	n_range.append(f)

score = list()
for n in n_range:
	s = sum([P[i][c] for i,c in enumerate(n)])
	score.append(s)

if score.index(max(score)) == 0:
	s = [P[i][1] for i in range(N)]
	print(max(s))
else:
	print(max(score))

Submission status: Wrong Answer

Solution code:
n = input()
f = [raw_input().split() for _ in xrange(n)]
p = [map(int, raw_input().split()) for _ in xrange(n)]
a = -9999999999L
for _ in xrange(1024):
    cnt, b = 0, '0' * (12 - len(bin(_))) + bin(_)[2:]
    for i, n in enumerate(f):
        ci = 0
        for x in xrange(10):
            if b[x] == n[x] and b[x] == '1':
                ci += 1
        cnt += (p[i][ci])
    if cnt == 0:
        continue
    a = max(cnt, a)
print a

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python

import re
import sys

def overlap(source, target):
    n = 0
    for s, t in zip(source, target):
        if s == 1 and s == t:
            n += 1
    return n

def main(argv):
    line = sys.stdin.readline()
    while line:
        n = int(line.rstrip("\n"))
        f = []
        for i in xrange(n):
            f.append(map(lambda x: int(x), 
              sys.stdin.readline().rstrip("\n").split(" ")))
        p = []
        for i in xrange(n):
            p.append(map(lambda x: int(x), 
              sys.stdin.readline().rstrip("\n").split(" ")))

        max_profit = -10**7 - 1
        for index in xrange(1, 2**10):
            profit = 0
            b = map(lambda x: int(x), bin(index)[2:].zfill(10))
            for i in xrange(n):
                c = overlap(b, f[i])
                profit += p[i][c]

            if profit > max_profit:
                max_profit = profit

        print max_profit
            
        line = sys.stdin.readline()

if __name__ == "__main__":
    main(sys.argv)

Submission status: Wrong Answer

Solution code:
import itertools
N=input()
F=[]
for i in range(N):
	F.append(map(int,raw_input().split()))
#print F

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


l=list(itertools.product(range(2), repeat=10))
#l=[(1, 1, 1, 1, 1, 0, 0, 0, 0, 0),(0, 0, 0, 0, 0, 1, 1, 1, 1, 1),(0, 0, 0, 0, 0, 1, 1, 1, 1, 1)]
l.remove((0, 0, 0, 0, 0, 0, 0, 0, 0, 0))

b=[[] for i in range(2**10)]

for ind_i,i in enumerate(l):
	for j in F:
		#print [min(t) for t in zip(i, j)]
		#print sum([min(t) for t in zip(i, j)])
		b[ind_i].append(sum([min(t) for t in zip(i, j)]))


b_sum=0
ans=float("-inf")
for ind_i,i in enumerate(b):
	b_sum=0
	for ind_j,j in enumerate(i):
		#print ind_i, ind_j,j
		b_sum+=P[ind_j][j]
	ans=max(ans,b_sum)

print ans

Submission status: Wrong Answer

Solution code:
N = int(input())
F = []
P = []
for i in range(N):
    a = list(map(int, input().split()))
    b = 0
    for j in range(5):
        if(a[j*2] == 0 & a[j*2+1] == 0):
            b += 1
        elif(a[j*2] == 1 & a[j*2+1] == 1):
            b += 2
        else:
            b += 1
    F.append(b)
for i in range(N):
    P.append(list(map(int, input().split()[0:F[i]])))

result = 0;
for i in P:
    result += max(i[1:])

print(result)

Submission status: Wrong Answer

Solution code:
N = int(raw_input())
lis = []
last = []
for num in xrange(N*2):
  lis.append( map(int,raw_input().split()) )
for a in xrange(2):
  for b in xrange(2):
    for c in xrange(2):
      for d in xrange(2):
        for e in xrange(2):
          for f in xrange(2):
            for g in xrange(2):
              for h in xrange(2):
                for i in xrange(2):
                  for j in xrange(2):
                    sumlis = []
                    for numb in xrange(N):
                      count = 0
                      for select in xrange(10):
                        check = [a,b,c,d,e,f,g,h,i,j]
                        if check == [0,0,0,0,0,0,0,0,0,0]:
                          continue
                        if check[select] == lis[numb][select]:
                          count += 1
                      sumlis.append(lis[numb + N][count])
                    last.append(sum(sumlis))
print max(last)

Submission status: Wrong Answer

Solution code:
N=int(input())
L=[0]*N;P=[0]*N;ans=0
for i in range(N):
    a=list(map(int,input().split()))
    for m in range(10):
        L[i]+=a[m]
for k in range(N):
    P[k]=list(map(int,input().split()))
for l in range(N):
    ans+=max(P[l][0:L[l]+1])
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
f = np.zeros((n, 10))
p = np.zeros((n, 11))
for i in range(n):
    f[i] = np.array(list(map(int, input().split())))

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

l = 10
f_n = 2**l-1
ans = (-10**7)*10*n
for i in range(2**l-1):
    ff = np.array(list(map(int,list(format(f_n,'b').zfill(l)))))
    print (ff)
    c = np.sum(ff*f, dtype=np.int64, axis=1)
    c = np.eye(11)[c]
    tmp = np.sum(c*p)
    if ans < tmp:
        ans = tmp
    f_n -= 1
    
print (int(ans))

Submission status: Wrong Answer

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

result = 0;

for i in P:
    result += max(i)

print(result)

Submission status: Wrong Answer

Solution code:
import itertools

def solve():
    N = int(input())
    F = []
    cnt_of_1 = []
    for _ in range(N):
        tmp_F = list(map(int, input().split(" ")))
        cnt_of_1.append(tmp_F.count(1))
        F.append(tmp_F)
    P = []
    zero_cmb = []
    for _ in range(N):
        tmp_P = list(map(int, input().split(" ")))
        zero_cmb.append(tmp_P[0])
        P.append(tmp_P)

    max_comb = []
    for i in range(N):
        P[i] = P[i][:cnt_of_1[i] + 1]
        """
        tmp_max = max(P[i])
        if tmp_max == P[i][0]:
            max_comb.append(max(P[i][1:]))
        else:
            max_comb.append(tmp_max)
        """
        max_comb.append(max(P[i]))

    """
    cmb = list(itertools.product(*P))
    target = cmb.index(tuple(zero_cmb))
    del cmb[target]
    maximum = -1000000000
    for ele in cmb:
        maximum = max(maximum, sum(ele))

    print(maximum)
    """
    max_comb.sort()
    max_comb.reverse()
    if max_comb[0] < 0:
        ans = max_comb[-1]
    else:
        ans = 0
        for ele in max_comb:
            if ele < 0:
                break
            else:
                ans += ele

    print(ans)
    
    
solve()

Submission status: Wrong Answer

Solution code:
import itertools


def solve():
    N = int(input())
    F = []
    cnt_of_1 = []
    for _ in range(N):
        tmp_F = list(map(int, input().split(" ")))
        cnt_of_1.append(tmp_F.count(1))
        F.append(tmp_F)
    P = []
    zero_cmb = []
    for _ in range(N):
        tmp_P = list(map(int, input().split(" ")))
        zero_cmb.append(tmp_P[0])
        P.append(tmp_P)

    max_comb = []
    for i in range(N):
        P[i] = P[i][:cnt_of_1[i] + 1]
        tmp_max = max(P[i])
        if tmp_max == P[i][0]:
            max_comb.append(max(P[i][1:]))
        else:
            max_comb.append(tmp_max)

    max_comb.sort()
    max_comb.reverse()
    if max_comb[0] < 0:
        ans = max_comb[-1]
    else:
        ans = 0
        for ele in max_comb:
            if ele < 0:
                break
            else:
                ans += ele

    print(ans)

    
solve()

Submission status: Wrong Answer

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

result = 0;

for i in P:
    print(i)
    result += max(i)

print(result)

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):
    sum_open = sum(F[i])
    ans += max(P[i][:sum_open+1])
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
f = np.zeros((n, 10))
p = np.zeros((n, 11))
for i in range(n):
    f[i] = np.array(list(map(int, input().split())))

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

l = 10
f_n = 2**l-1
ans = (-10**7)*10
for i in range(2**l-1):
    ff = np.array(list(map(int,list(format(f_n,'b').zfill(l)))))
    c = np.sum(ff*f, dtype=np.int64, axis=1)
    c = np.eye(11)[c]
    tmp = np.sum(c*p)
    if ans < tmp:
        ans = tmp
    f_n -= 1
    
print (int(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)]

benefits = -10000000

for t in range(1,1024):
  bits = list(bin(t))
  a = [0 for _ in range(n)]
  jk = 0
  while jk < 10:
    b = bits.pop()
    if b == "b":
      break
    elif b == "0":
      jk += 1
      continue
    else:
      for i in range(n):
        if f[i][jk]:
          a[i] += 1
      jk += 1
  
  s = 0
  for i in range(n):
    s += p[i][a[i]]
  else:
    benefits = max(s,benefits)
else:
  print(benefits)

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):
    sum_open = sum(F[i])
    ans += max(P[i][1:sum_open+1])
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
f = []
p = []
for i in range(n):
    f.append(list(map(int, input().split())))
for i in range(n):
    p.append(list(map(int, input().split())))

ps = []
flag = 0
for i in range(n):
    s = sum(f[i])
    m = max(np.array(p[i])[:s+1])
    flag += np.argmax(np.array(p[i])[:s+1])
    ps.append(m)
if flag == 0:
    ans = 0
    for i in range(n):
        ans += p[i][f[i][0]]
    for i in range(1, 10):
        tmp = 0
        for j in range(n):
            tmp += p[j][f[j][i]]
        ans = max(ans, tmp)
    print(ans)
else:
    print(sum(ps))

Submission status: Wrong Answer

Solution code:
N = int(input())
F = list()
P = list()
for i in range(N):
	f = list(map(int, input().split()))
	#F.append([f[0:2],f[2:4],f[4:6],f[6:8],f[8:10]])
	F.append(f)
for i in range(N):
	p = list(map(int, input().split()))
	P.append(p)


count = [0] * N

n_range = [sum(F[i]) for i in range(N)]
index = []
score = []
for i in range(N):
	s = max(P[i][:n_range[i]+1])
	score.append(s)
	index.append(P[i].index(s))

if sum(index) == 0:
	s = [P[i][1] for i in range(N)]
	print(max(s))
else:
	print(sum(score))

Submission status: Wrong Answer

Solution code:
from itertools import product

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

max_res = -10**8

for i,j in enumerate(product("01",repeat=10)):
    if i != 0:
        res = [0 for _ in range(N)]
        for k, flag in enumerate(j):
            if flag == "1":
                for l,f in enumerate(F):
                    if f[k] == "1":
                        res[l] += 1
        buf = 0
        for m in range(N):
            buf += int(P[m][res[m]])
        max_res = max(buf,max_res)

print(max_res)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""abc080_c"""


import sys


def numFromBitList(l):
    """Get number from bit list."""
    n = 0
    for i, v in enumerate(l):
        n += v * 2 ** i
    return n

def main():
    """Main function."""
    n = int(input())

    fs = []
    for _ in range(n):
        fs.append(numFromBitList(list(map(int, input().split(' ')))))

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

    max_ = -100000000
    for i in range(1, 1024):
        profit = 0
        for idx, f in enumerate(fs):
            profit += ps[idx][bin(i & f)[2:].count('1')]
        max_ = max(max_, profit)

    print(max_)


if __name__ == '__main__':
    sys.exit(main())

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    F = tuple(tuple(map(int, input().split())) for _ in [0] * N)
    P = tuple(tuple(map(int, input().split())) for _ in [0] * N)

    c = [0] * N
    for i in range(N):
        c[i] = sum(F[i])

    profit = [0] * N
    for i, j in enumerate(c):
        p = -float('inf')
        for k in range(1, j + 1):
            p = max(P[i][k], p)
        profit[i] = p

    total = sum([i for i  in profit if i > 0])
    if not total:
        print(max(profit))
    else:
        print(total)

main()