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

# 全て試す。
li = list(product([0, 1], repeat=10))

ans = - 10 ** 19
for i in li:
  cnt = 0
  for f, p in zip(F, P):
    opendays = sum([a * b for a, b in zip(i, f)])
    cnt += p[opendays]
  ans = max(ans, cnt)
print(ans)

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

# 全て試す。
li = list(product([0, 1], repeat=10))

ans = 0
for i in li:
  cnt = 0
  for f, p in zip(F, P):
    opendays = sum([a * b for a, b in zip(i, f)])
    cnt += p[opendays]
  ans = max(ans, cnt)
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 7)

N = int(input())
flist = [list(map(int, input().split())) for _ in range(N)]
plist = [list(map(int, input().split())) for _ in range(N)]
alist = [0] * 10
def dfs(i, v, ans):
    if v == 10:
        tmp = 0
        if alist.count(1) == 0:
            return ans
        for j in range(N):
            cnt = 0
            for k in range(10):
                if alist[k] == 1 and flist[j][k] == 1:
                   cnt += 1
            tmp += plist[j][cnt]

        ans = max(ans, tmp)
        return ans

    alist[i] = 1
    ans = dfs(i + 1, v + 1, ans)
    alist[i] = 0
    ans = dfs(i + 1, v + 1, ans)
    return ans

print(dfs(0, 0, -10 ** 7 - 1))

Submission status: Wrong Answer

Solution code:
plans = []
def dfs(i, array):
    if i == 10:
        if sum(array) > 0:
            plans.append(list(array))
    else:
        array[i] = 0
        dfs(i+1, array)

        array[i] = 1
        dfs(i+1, array)

dfs(0, [0 for _ in range(10)])


N = int(input())
Fs = [[int(f) for f in input().split(' ')] for _ in range(N)]
Ps = [[int(f) for f in input().split(' ')] for _ in range(N)]

ans = -10000
for plan in plans:
    price = 0
    for i, F in enumerate(Fs):
        n = sum([1 for f, p in zip(F, plan)
                 if f == 1 and p == 1])
        price += Ps[i][n]

    ans = max(ans, price)

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
Fa = [list(map(int,input().split())) for i in range(N)]
P = [list(map(int,input().split())) for i in range(N)]
F = np.array(Fa)
ans = - 10**8
for i in range(1,2**10):
    tmp = 0
    joi = np.array(list(map(int,format(i,"010b"))))
    for j in range(N):
        tmp += P[j][np.dot(joi,F[j])]
    ans = max(tmp, ans)
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

N = int(input().strip())

openhour = [0] * 10
samehour = [0] * N

F = [0] * N
P = [0] * N
for i in range(N):
    F[i] = [int(x) for x in input().strip().split()]
for i in range(N):
    P[i] = [int(x) for x in input().strip().split()]

def f(i, openhour, samehour):
    if i == 10:
        if sum(openhour) == 0:
            return - 10 ** 9 + 7
        global N, F, P
        ret = sum([P[n][samehour[n]] for n in range(N)])
        return ret
    oh1 = openhour[:]
    oh2 = openhour[:]
    oh1[i] = 0
    oh2[i] = 1
    sh2 = samehour[:]
    for n in range(N):
        if F[n][i] == 1:
            sh2[n] += 1

    return max(f(i+1, oh1[:], samehour[:]),f(i+1, oh2[:], sh2[:]))

print(f(0, openhour[:], samehour[:]))

Submission status: Wrong Answer

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

ans = -10**18
for i in range(2**10+1, 2**11-1):
    num = 0
    b = bin(i)
    for j in range(N):
        cnt = 0
        for k in range(10):
            if F[j][k] == 1 and b[k+3] == "1":
                cnt += 1
        num += P[j][cnt]
    ans = max(ans, num)
    
print(ans)

Submission status: Wrong Answer

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

ans = -10**9-7
for i in range(2**10+1, 2**11-1):
    num = 0
    b = bin(i)
    for j in range(N):
        cnt = 0
        for k in range(10):
            if F[j][k] == 1 and b[k+3] == "1":
                cnt += 1
        num += P[j][cnt]
    ans = max(ans, num)
    
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
#shopの営業データ
shopData = []
#得点ドンぐらいとれるか
point = []
for i in range(n):
    shopData.append(list(map(int, input().split())))
for i in range(n):
    point.append(list(map(int, input().split())))
#最大値
global max_point
max_point = - (10 ** 7)
def searchMaxOpen(data, n):
    if n == 10:
        calcMax(data)
    else:
        data[n] = 1
        searchMaxOpen(data,n + 1)
        data[n] = 0
        searchMaxOpen(data, n + 1)

def calcMax(data):
    global max_point
    earnPoint = 0
    if 1 in data:
        for i in range(n):
            count = 0
            for j in range(10):
                if shopData[i][j] == data[j] and data[j] == 1:
                    count += 1
            earnPoint += point[i][count]
    else:
        return
    if earnPoint > max_point:
        max_point = earnPoint

start = [None] * 10
searchMaxOpen(start, 0)
print(max_point)

Submission status: Wrong Answer

Solution code:
n = int(input())
#shopの営業データ
shopData = []
#得点ドンぐらいとれるか
point = []
for i in range(n):
    shopData.append(list(map(int, input().split())))
for i in range(n):
    point.append(list(map(int, input().split())))
#最大値
global max_point

max_point = - 10 ** 7
def searchMaxOpen(data, n):
    if n == 10:
        calcMax(data)
    else:
        data[n] = 1
        searchMaxOpen(data,n+1)
        data[n] = 0
        searchMaxOpen(data, n+1)

def calcMax(data):
    global max_point
    earnPoint = 0
    if 1 in data:
        for i in range(n):
            count = 0
            for j in range(10):
                if shopData[i][j] == data[j] and data[j] == 1:
                    count += 1
            earnPoint += point[i][count]
    else:
        return
    if earnPoint > max_point:
        max_point = earnPoint

start = [None] * 10
searchMaxOpen(start, 0)

print(max_point)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import itertools

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)]
    bit_list = list(itertools.product([0, 1], repeat=10))
    bit_list.pop(0)
    answer = -10**7-1
    for b in bit_list:
        profit = 0
        for i in range(N):
            a = 0 ## 一致してる営業時間の数
            for j in range(10):
                if b[j]==1 and F[i][j]==1:
                    a+=1
            profit+=P[i][a]

        answer = max(answer,profit)

    print(answer)
    return 

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# bit演算, 全探索で多分いける
def input():
    import sys
    return sys.stdin.readline().rstrip()


def main():
    import math
    import collections
    import itertools

    n = int(input())
    fs = [int(input().replace(' ', ''), 2) for _ in range(n)]
    # print(fs)
    ps = [list(map(int, input().split())) for _ in range(n)]
    # print(ps)
    ans = -float("INF")
    for i in range(1, 2 ** 10 - 1):
        num_simal_stores = [bin(i & f).count('1') for f in fs]
    
        ans_tmp = 0
        for i in range(n):
            ans_tmp += ps[i][num_simal_stores[i]]

        ans = max(ans, ans_tmp)
    
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
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())))

ans = -10**9
for i in range(1,2**11): #ビット全探索 
    opn = [0 for i in range(10)]
    scr = 0

    for j in range(10):
        memo = (i>>j)
    
    

        if memo&1:
            opn[j] = 1
    
    for k in range(n):
        cnt = 0
        for l in range(10):
            if opn[l] and f[k][l]:
                cnt += 1
        scr += p[k][cnt]

    ans = max(scr,ans)

print(ans)

Submission status: Wrong Answer

Solution code:
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())))

ans = -10**8
for i in range(1,2**10): #ビット全探索 
    opn = [0 for i in range(10)]
    scr = 0

    for j in range(10):
        memo = i>>j

        if memo&1:
            opn[j] = 1

    for k in range(n):
        cnt = 0
        for l in range(10):
            if opn[l] and f[k][l]:
                cnt += 1
        scr += p[k][cnt]

    ans = max(scr,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**8)
for i in range(1, 2**10):
    tmp = 0
    for j in range(N):
        count = 0
        for k in range(10):
            if F[j][k] == 1 and (i >> k) % 2 == 1:
                count += 1
        tmp += P[j][count]

    ans = max(ans, tmp)

print(ans)

Submission status: Wrong Answer

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

shop = [0]*10
ans = -1 * 10**8
for i in range(1, 2**10):
    tmp = 0
    for j in range(N):
        count = 0
        for k in range(10):
            if F[j][k] == 1 and (i >> k) % 2 == 1:
                count += 1
        tmp += P[j][count]

    ans = max(ans, tmp)

print(ans)

Submission status: Wrong Answer

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

ans = -1e8
for i in range(1, 2**10):
    s = 0
    for j in range(n):
        tmp = int(F[j], 2)
        tmp = i & tmp
        c = bin(tmp).count("1")
        s += P[j][c]
    if s > ans:
        ans = s
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs= sys.stdin.buffer.readlines
#rstrip().decode('utf-8')

import numpy as np
#import operator
#from heapq import heapify,heappop,heappush
#from math import gcd
#from fractions import gcd
#from collections import deque
#from collections import defaultdict
#from collections import Counter
#from itertools import accumulate
#from itertools import groupby
#from itertools import permutations
#from itertools import combinations
#from scipy.sparse import csr_matrix
#from scipy.sparse.csgraph import floyd_warshall
#from scipy.sparse.csgraph import csgraph_from_dense
#from scipy.sparse.csgraph import dijkstra
#sys.setrecursionlimit(10**7)

#map(int,input().split())

def main():
    N=int(input())
    F=np.array([list(map(int,input().split())) for _ in range(N)])
    P=np.array([list(map(int,input().split())) for _ in range(N)])
    ans=-10**9
    for i in range(1,1<<10-1):
        tmp=0
        for j in range(N):
            cnt=0
            for k in range(10):
                if (i>>k)&(F[j,k])==1:
                    cnt+=1
            tmp+=P[j,cnt+1]
        ans=max(ans,tmp)
    print(ans)






if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs= sys.stdin.buffer.readlines
#rstrip().decode('utf-8')

import numpy as np
#import operator
#from heapq import heapify,heappop,heappush
#from math import gcd
#from fractions import gcd
#from collections import deque
#from collections import defaultdict
#from collections import Counter
#from itertools import accumulate
#from itertools import groupby
#from itertools import permutations
#from itertools import combinations
#from scipy.sparse import csr_matrix
#from scipy.sparse.csgraph import floyd_warshall
#from scipy.sparse.csgraph import csgraph_from_dense
#from scipy.sparse.csgraph import dijkstra
#sys.setrecursionlimit(10**7)

#map(int,input().split())

def main():
    N=int(input())
    F=np.array([list(map(int,input().split())) for _ in range(N)])
    P=np.array([list(map(int,input().split())) for _ in range(N)])
    ans=-10**9
    for i in range(1,1<<10-1):
        tmp=0
        for j in range(N):
            cnt=0
            for k in range(10):
                if (i>>k)&(F[j,k])==1:
                    cnt+=1
            tmp+=P[j,cnt]
        ans=max(ans,tmp)
    print(ans)






if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
def inputs():return [int(x) for x in input().split()]
f = [inputs() for _ in range(N)]
p = [inputs() for _ in range(N)]
cnt =[0]*(N)
ans = -10**8
for bit in range(1,1<<10):
    ans1 = 0
    cnt =[0]*(N)
    for j in range(10):
        for i in range(N):
            if bit&1<<j and f[i][j]==1:
                cnt[i] +=1
    ans1 += sum([p[i][cnt[i]] for i in range(N)])
    ans = max(ans1,ans)
print(ans)

Submission status: Wrong Answer

Solution code:
import itertools
N = int(input())
F = [list(map(int,input().split())) for _ in range(N)]
F.insert(0,[0])
P = [list(map(int,input().split())) for _ in range(N)]
P.insert(0,[0])
cmax = 0
for x in itertools.product((0,1),repeat=10):
    cnt = 0
    for i in range(1,N+1):
        c = 0
        for j in range(10):
            if x[j]==1 and F[i][j]==1:
                c += 1
        cnt += P[i][c]
    cmax = max(cmax,cnt)
print(cmax)

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  l1=[]

  for _ in range(n):
    l1.append(sum(LI()))

  l2=[LI() for _ in range(n)]

  ans=0
  f=True
  mn=-inf
  for i in range(n):
    x=l1[i]
    y=l2[i]
    _ans=max(y[:x+1])
    if _ans==y[0]:
      if y[:x+1].count(_ans)>1:
        f=False
      mn=max(mn,max(y[1:x+1]))
    else:
      f=False
    ans+=_ans

  if f:
    return mn
  return max(ans,mn)

# main()
print(main())

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  l1=[]

  for _ in range(n):
    l1.append(sum(LI()))

  l2=[LI() for _ in range(n)]

  ans=0
  f=True
  mn=-inf
  for i in range(n):
    x=l1[i]
    y=l2[i]
    _ans=max(y[:x+1])
    if _ans==y[0]:
      if y[:x+1].count(_ans)>1:
        f=False
      else:
        mn=max(mn,max(y[1:x+1]))
    else:
      f=False
    ans+=_ans

  if f:
    return mn
  return ans

# main()
print(main())

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  l1=[]

  for _ in range(n):
    l1.append(sum(LI()))

  l2=[LI() for _ in range(n)]

  ans=0
  f=True
  mn=-inf
  for i in range(n):
    x=l1[i]
    y=l2[i]
    _ans=max(y[:x+1])
    if _ans==y[0]:
      if y.count(_ans)>1:
        f=False
      else:
        mn=max(mn,max(y[1:x+1]))
    else:
      f=False
    ans+=_ans

  if f:
    return mn
  return ans

# main()
print(main())

Submission status: Wrong Answer

Solution code:
from itertools import product

n = int(input())
f_all = []
for i in range(n):
    fi = list(map(int, input().split()))
    f_all.append(fi)
p_all = []
for i in range(n):
    pi = list(map(int, input().split()))
    p_all.append(pi)

res = -999999999
for pro in product([0, 1], repeat=10):
    if sum(pro) == 0:
        continue
    total = 0
    for i in range(n):
        count = 0
        for j in range(10):
            if pro[j] == 1 and f_all[i][j] == 1:
                count += 1
        total += p_all[i][count]
    res = max(res, total)
print(res)

Submission status: Wrong Answer

Solution code:
N = int(input())
F = []
P = []
for i in range(N):
    F.append(list(map(int, input().split())))
for j in range(N):
    P.append(list(map(int, input().split())))
even_list = []
odd_list = []
for i in range(N):
    even_sum = 0
    odd_sum = 0
    for j in range(5):
        even_sum += F[i][0::2][j]*P[i][2*j]
        odd_sum += F[i][1::2][j]*P[i][2*j+1]
    even_list.append(even_sum)
    odd_list.append(odd_sum)
print(max(sum(even_list), sum(odd_list)))

Submission status: Wrong Answer

Solution code:
def cc080():
    n = int(input())
    fn = list()
    pn = list()
    for i in range(0, n):
        fn.append(list(map(int, input().split())).count(1))
    for i in range(0, n):
        pn.append(list(map(int, input().split())))

    close = True
    mi = 10000000
    tp = 0
    for i in range(0, n):
        clo = pn[i][0]
        ope = max(pn[i][1:fn[i]+1])
        tp += max([clo, ope])
        if close and max([clo, ope]) == clo:
            mi = min([mi, ope])
        else:
            close = False
    if close:
        tp -= abs(mi)

    print(tp)

cc080()

Submission status: Wrong Answer

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

def main(N,F,P):
    inf = float("INF")
    ans = -inf
    print(F,P)
    
    for i in range(1,1<<10):
        count = [0]*N
        tmp = 0
        for j in range(10):
            if((i>>j)&1):
                for k in range(N):
                    if F[k][j]==1:
                        count[k] += 1
            else:
                continue
            
        for l in range(N):
            tmp += P[l][count[l]]
        ans = max(ans,tmp)
    print(ans)

if __name__ == '__main__':
    N = int(input())
    F,P = [],[]
    for i in range(N):
        F.append([int(j) for j in input().split()])
    for i in range(N):
        P.append([int(j) for j in input().split()])
    main(N,F,P)

Submission status: Wrong Answer

Solution code:
n = int(input())
f = []
for _ in range(n):
    s = 0
    l = list(map(int, input().split()))
    for i in range(10):
        s += l[i]<<i
    f.append(s)
p = [list(map(int, input().split())) for _ in range(n)]
b = []
for i in range(1,1023):
    w = 0
    for j in range(n):
        idx = format(i & f[j], 'b').count('1')
        w += p[j][idx]
    b.append(w)
print(max(b))

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
from itertools import product

input = sys.stdin.readline

N = int(input())

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

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

def cal(f, p, v):
    total = 0
    max_total = -10**8
    c = np.dot(f, v.T)
    for ci in c.T:
        total = sum([p[i,cii] for i, cii in enumerate(ci)])
        max_total = max(total, max_total)
    return max_total

v = np.array(list(product([0,1],repeat=10)))
v[0] = np.array([0,0,0,0,0,0,0,0,0,1])

print(cal(f, p, v))

Submission status: Wrong Answer

Solution code:
"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]
"""

import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

if __name__ == "__main__":
    n = int(sys.stdin.readline())
    f = [list(map(int,list(sys.stdin.readline().split()))) for i in range(n)]  # 二次元配列入力　二次元マップみたいな入力のとき
    p = [list(map(int,list(sys.stdin.readline().split()))) for i in range(n)]  # 二次元配列入力　二次元マップみたいな入力のとき
    
    ans = -999999999
    #集合に含まれる部分集合全パターンだけループ
    for item in range(1,2**10):#試行回数（10個の時間帯で店開く開かないを考える）
        fund = 0
        #被る被らない
        for i in range(n):#n個のお店
            cou = 0#カウンタ。利益を表す。
            for x in range(10):#月-金(5) * 2
                if (item >> x) % 2 == 1 and f[i][x] == 1:#itemを右にx回ビットシフト(/2)させてお店iとともに奇数＝被っていたら
                    cou += 1#店を開けるのが被っていたらカウンタを更新
            fund += p[i][cou]#お店iにおけるカウンタ分の時間帯の利益を足す。
        ans = max(ans, fund)#最大問題なので大きくなれば更新
    print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
count = []
for i in range(n):
  a1 = list(map(int, input().split()))
  n1 = a1.count(1)
  count.append(n1)
ans = 0
for i in range(n):
  moya = count[:count[i]]
  ans += max(moya)
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
F = [int(input().replace(' ', ''), 2) for i in range(N)]
P = [[int(j) for j in input().split()] for j in range(N)]

ans = -float('inf')

for i in range(1, 2**10):
    temp = 0
    for j in range(N):
        temp += P[j][bin(i&F[j]).count('1')]
        ans = max(ans, temp)

print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
f=[0 for i in range(n)]
for i in range(n):
    fi=int("".join(list(input().split())),2)
    f[i] = fi
print(f)
p=[[] for i in range(n)]
for i in range(n):
    pi=list(map(int,input().split()))
    p[i] = pi
print(p)
ans=-9999999999999
for i in range(1,1024):
    bene=0
    for j in range(n):
        c = str(bin(i & f[j])).count("1")
        bene+=p[j][c]
    if(ans < bene):
        ans = bene
print(ans)

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)

import itertools

data = [0,1,2,3,4,5,6,7,8,9]

ans_max = -10**7


for i in range(1,11):
    for s in list(itertools.combinations(data,i)):
        ans = 0
        
        a = [0,0,0,0,0,0,0,0,0,0]
                
        for j in s:
            a[j]=1
        
        for k in range(N):
            cnt = 0
            for l in range(10):
                if F[k][l] == a[l] and a[l]==1:
                    cnt += 1
            ans += P[k][cnt]
        if ans > ans_max:
            ans_max = ans

print(ans_max)

Submission status: Wrong Answer

Solution code:
n = int(input())
fs = [list(map(int, input().split())) for _ in range(n)]
ps = [list(map(int, input().split())) for _ in range(n)]
res = -float('inf')
for i in range(1, 2**10):
    s = list(map(int, list(bin(i)[2:])))
    val = 0
    for f, p in zip(fs, ps):
        count = 0
        for a, b in zip(s, f):
            if a == 1 and b == 1:
                count += 1
        val += p[count]
    res = max(res, val)
print(res)

Submission status: Wrong Answer

Solution code:
from itertools import product
import numpy as np
N = int(input())
F = np.array([list(map(int, input().split())) for _ in range(N)])
P = np.array([list(map(int, input().split())) for _ in range(N)])
M = np.array([0]*1024)
for i, f in enumerate(product([0, 1], repeat=10)) :
    if f == [0]*10 : continue
    f = np.array(f)
    a = np.sum(F*f, axis=1)
    M[i] = sum([l[i] for l, i in zip(P, a)])
print(np.max(M))

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

for i in range(1,2**10):
  a=0
  for f,p in zip(F,P):
    a+=p[bin(f&i).count('1')]
  ans=max(ans,a)
print(ans)

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=0
a=0

for i in range(1,2**10):
  a=0
  for f,p in zip(F,P):
    a+=p[bin(f&i).count('1')]
  ans=max(ans,a)
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
store = [int(input().replace(" ",""),2) for _ in range(N)]
pro = [list(map(int,input().split())) for _ in range(N)]
total_pro = 0
ans = -10**7
for joi in range(1,2**10):
  total_pro = 0
  for x in range(N):
    total_pro+= pro[x][bin(joi&store[x]).count("1")]
  ans = max(ans,total_pro)
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
store = [int(input().replace(" ",""),2) for _ in range(N)]
pro = [list(map(int,input().split())) for _ in range(N)]
ans = -99999999
total_pro = 0
for joi in range(1,2**10):
  for x in range(N):
    total_pro+= pro[x][bin(joi&store[x]).count("1")]
  ans = max(ans,total_pro)
  total_pro = 0
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
run = [input().replace(" ","") for _ in range(N)]
pro = [list(map(int,input().split())) for _ in range(N)]
ans = -99999999
total_pro = 0
cal = ["0","1"]
for i in cal:
  for j in cal:
    for k in cal:
      for l in cal:
        for m in cal:
          for n in cal:
            for o in cal:
              for p in cal:
                for q in cal:
                  for r in cal:
                    if i==j==k==l==m==n==o==p==q==r=="0":
                      pass
                    else:
                      joi = int(i+j+k+l+m+n+o+p+q+r,2)
                      for x in range(N):
                         store = int(run[x],2)
                         total_pro += pro[x][bin(joi&store).count("1")]
                      ans = max(ans,total_pro)
                      total_pro = 0
print(ans)

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


def dfs(day, state):
    if 5 == day:
        if 0 == sum(state):
            return -10 ** 7
        counts = [0 for _ in range(n)]
        for i in range(5):
            for j in range(n):
                if 1 == state[2 * i] and 1 == f[j][2 * i]:
                    counts[j] += 1
                if 1 == state[2 * i + 1] and 1 == f[j][2 * i + 1]:
                    counts[j] += 1
        profit = 0
        for i in range(n):
            profit += p[i][counts[i]]
        return profit
    canddiates = []
    state[2 * day] = 0
    canddiates.append(dfs(day + 1, state))
    state[2 * day] = 1
    canddiates.append(dfs(day + 1, state))
    state[2 * day + 1] = 0
    canddiates.append(dfs(day + 1, state))
    state[2 * day + 1] = 1
    canddiates.append(dfs(day + 1, state))
    return max(canddiates)


state = [0 for _ in range(10)]
print(dfs(0, state))

Submission status: Wrong Answer

Solution code:
N = int(input())

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

ans = 0
holiday_profits = []
holiday = 0
for i in range(N):
    profits = P[i][:F[i]+1]
    ans += max(profits)
    # 稼働しないのが一番儲かるか
    if len([x for x in profits if x > profits[0]]) == 0:
        holiday += 1
        holiday_profits.extend(profits[1:])

if holiday == N:
    ans += sorted(holiday_profits)[-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)]
p2=[]
l=[]
for i in range(n):
    p2.append([p[i][j] for j in range(f[i].count(1))])
    l.append(max(p2[i]))
#print(l)
print(sum(l))

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc080/tasks/abc080_c
# C - Shopping Street
import itertools
N = int(input().split()[0])
f_list_list = []

for _ in range(N):
    f_list_list.append(list(map(int, input().split())))

p_list_list = []

for _ in range(N):
    p_list_list.append(list(map(int, input().split())))

# total_p_list = [sum(p_list) for p_list in list(zip(*p_list_list))]
p_gen = itertools.product([0, 1], repeat=10)
max_p = -float('inf')
for pattern in p_gen:  # 1024
    if sum(pattern) == 0:
        continue
    counter = {k: 0 for k in range(N)}
    for t_i, is_open in enumerate(pattern):  # 10
        if is_open == 0:
            continue
        for n_i in range(N):  # 100
            if f_list_list[n_i][t_i] == 1:
                counter[n_i] += 1
    total_p = 0
    for k, c in counter.items():  # 100
        if c == 0:
            continue
        total_p += p_list_list[k][c]
    max_p = max(total_p, max_p)


print(max_p)