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())
A=[list(map(int,input().split())) for i in range(N)]
B=[list(map(int,input().split())) for i in range(N)] 

import itertools
D=list(itertools.product([0,1],repeat=10))

ans=(-1)*99999999
for i in D:
  a=0
  if i!=(0,0,0,0,0,0,0,0,0,0):
    for j in range(N):
      b=0
      for k in range(10):
        if i[k]==1 and A[j][k]==1:
          b+=1
      a+=B[j][b]
    ans=max(ans,a)
print(ans)

Submission status: Wrong Answer

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

import itertools
D=list(itertools.product([0,1],repeat=10))

ans=(-1)*10**7
for i in D:
  a=0
  if i!=(0,0,0,0,0,0,0,0,0,0):
    for j in range(N):
      b=0
      for k in range(10):
        if i[k]==1 and A[j][k]==1:
          b+=1
      a+=B[j][b]
    ans=max(ans,a)
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)]

result = 0
for i in range(1, 1025):
    t = 0
    for j in range(N):
        c = 0
        for k in range(10):
            c += (i >> k & 1) & F[j][k]
        t += P[j][c]
    result = max(result, t)
print(result)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30
from itertools import permutations

def main():
    n = int(input().strip())
    f = [0] * n
    p = [[] for _ in range(n)]
    for i in range(n):
        tmp = list(map(int, input().strip().split()))
        for j in range(10):
            f[i] += tmp[9-j] << j
            # print('f[i]', f[i])
    for i in range(n):
        p[i] = list(map(int, input().strip().split()))
    
    ans = -INF
    b = 0
    for b in range(1, 2**10-1):
        m = 0
        for j in range(n):
            v = fun(f[j], b)
            # print('f: ', v)
            m += p[j][v]
        ans = max(ans, m)
    print(ans)

def fun(f, q):
    ans = 0
    # print(bin(f), bin(q))

    r = f & q
    # print(bin(r))
    for i in range(10):
        ans += (r >> i) & 0x1
    return ans



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
arr = [list(map(int, input().split())) for i in range(n)]
arm = [list(map(int, input().split())) for j in range(n)]  # 入力

ans = -9999999999  # 最小
for item in range(1, (1<<10)):  # 2 ** 10 == 1024
    fund = 0
    for i in range(n):  # 店の数
        cou = 0  # かぶる数
        for x in range(10):  # 月-金(5) * 2
            print(i,x,item >> x, (item >> x)%2)
            if (item >> x) % 2 == 1 and arr[i][x] == 1:  # その時間で被るかどうか
                cou += 1
        fund += arm[i][cou]
    ans = max(ans, fund)  # 最大値更新

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)]
P0 = []
for i in range(N):
  P0.append(P[i][0])
ans = []
for i in range(N):
  c = F[i].count(1)
  m = max(P[i][1:c+1])
  ans.append(m)
l = []
for i in zip(P0, ans):
  l.append([i,i[0]-i[1]])
l = sorted(l, key=lambda x:-x[1])
ans1 = 0
cnt = 0
if len(ans) == 1:
  print(*ans)
else:
  for i in range(N):
    if l[i][0][0] > l[i][0][1]:
      cnt += 1
      if cnt == len(P0):
        ans1 += l[i][0][1]
        break
      ans1 += l[i][0][0]
    else:
      ans1 += l[i][0][1]
  print(ans1)

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)]
P0 = []
for i in range(N):
  P0.append(P[i][0])
ans = []
for i in range(N):
  c = F[i].count(1)
  m = max(P[i][1:c+1])
  ans.append(m)
ans2 = -float("inf")
if len(ans) == 1:
  print(*ans)
else:
  for i in range(N):
      ans1 = P0[i] + sum(ans[:i]) + sum(ans[i+1:])
      ans2 = max(ans2, sum(ans), ans1)
  print(ans2)

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc080/tasks/abc080_c
# 普通にbit全探索では？

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

bitlen = 10


def ret_score(n: int):
    # 営業時間かぶり計算
    C = []
    for i in range(N):  # Nでiter
        cnt = 0
        for bit in range(bitlen):  # 桁とFを対応
            if ((n >> bit) & 1) and F[i][bit]:  # もし1その桁で1なら
                cnt += 1
        C.append(cnt)

    # スコア計算
    ret = 0
    for i, c in enumerate(C):
        ret += P[i][c]
    return ret


ans = -10**9 + 1
for n in range(1, 1 << bitlen):
    ans = max(ans, ret_score(n))
print(ans)

Submission status: Wrong Answer

Solution code:
import itertools 

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())))
#最大値
data = list(itertools.product(range(2), repeat = 10))
del data[0]
max_point = - (10 ** 7)
for shop in data:
    cand = 0
    for i in range(len(shopData)):
        count = 0
        for j in range(10):
            if shop[j] == 1 and shopData[i][j] == 1:
                count += 1
        cand += point[i][count]
    max_point = max(max_point, cand)
print(max_point)

Submission status: Wrong Answer

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

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 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 LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

def main():
    N = I()
    F = []
    P = []
    n_open_time = [0] * N
    selected_ix = set()
    least_ans = -inf
    cur_ans = 0
    for i in range(N):
        f = LI()
        F.append(f)
        n_open_time[i] = sum(f)
    for _ in range(N):
        p = LI()
        P.append(p)
    for i in range(N):
        n_open = n_open_time[i]
        cur_ans += max(P[i][:n_open+1])
    print(cur_ans)
    '''
    for i in range(N):
        n_open = n_open_time[i]
        i_max_prof = -1
        ix_max_prof = 0
        for j in range(n_open+1):
            if i_max_prof <= P[i][j]:
                i_max_prof = P[i][j]
                ix_max_prof = j
        cur_ans += i_max_prof
        selected_ix.add(ix_max_prof)
        if n_open > 0:
            least_ans = max(least_ans, max(P[i][1:n_open+1]))
    if len(selected_ix) == 1 and 0 in selected_ix:
        print(least_ans)
    else:
    '''

main()

Submission status: Wrong Answer

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

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 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 LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N = I()
    F = []
    P = []
    n_open_time = [0] * N
    selected_ix = set()
    least_ans = -inf
    cur_ans = 0
    for i in range(N):
        f = LI()
        F.append(f)
        n_open_time[i] = sum(f)
    for _ in range(N):
        p = LI()
        P.append(p)
    for i in range(N):
        n_open = n_open_time[i]
        i_max_prof = -1
        ix_max_prof = 0
        for j in range(n_open+1):
            if i_max_prof <= P[i][j]:
                i_max_prof = P[i][j]
                ix_max_prof = j
        cur_ans += i_max_prof
        selected_ix.add(ix_max_prof)
        if n_open > 0:
            least_ans = max(least_ans, max(P[i][1:n_open+1]))
    '''
    if len(selected_ix) == 1 and 0 in selected_ix:
        print(least_ans)
    else:
    '''
    print(cur_ans)

main()

Submission status: Wrong Answer

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

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 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 LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N = I()
    F = []
    P = []
    n_open_time = [0] * N
    selected_ix = set()
    least_ans = -inf
    cur_ans = 0
    for i in range(N):
        f = LI()
        F.append(f)
        n_open_time[i] = sum(f)
    for _ in range(N):
        p = LI()
        P.append(p)
    for i in range(N):
        n_open = n_open_time[i]
        i_max_prof = -1
        ix_max_prof = -1
        for j in range(n_open+1):
            if i_max_prof <= P[i][j]:
                i_max_prof = P[i][j]
                ix_max_prof = j
        cur_ans += i_max_prof
        selected_ix.add(ix_max_prof)
        if n_open > 0:
            least_ans = max(least_ans, max(P[i][1:n_open+1]))
    if len(selected_ix) == 1 and 0 in selected_ix:
        print(least_ans)
    else:
        print(cur_ans)

main()

Submission status: Wrong Answer

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

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 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 LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N = I()
    F = []
    P = []
    n_open_time = [0] * N
    selected_ix = set()
    least_ans = -inf
    cur_ans = 0
    for i in range(N):
        f = LI()
        F.append(f)
        n_open_time[i] = sum(f)
    for _ in range(N):
        p = LI()
        P.append(p)
    for i in range(N):
        n_open = n_open_time[i]
        i_max_prof = -1
        ix_max_prof = -1
        for j in range(n_open+1):
            if i_max_prof < P[i][j]:
                i_max_prof = P[i][j]
                ix_max_prof = j
        cur_ans += i_max_prof
        selected_ix.add(ix_max_prof)
        if n_open > 0:
            least_ans = max(least_ans, max(P[i][1:n_open+1]))
    if len(selected_ix) == 1 and 0 in selected_ix:
        print(least_ans)
    else:
        print(cur_ans)

main()

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 = -10000009
for i in range(1, 2 ** 10):
        tmp = 0
        check = [0] * N
        for j in range(10):
                if ((i >> j) & 1):
                        for k in range(N):
                                if F[k][j]:
                                        check[k] += 1
        for k in range(N):
                tmp += P[k][check[k]]
        ans = max(ans, tmp)
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
F = [sum(map(int, input().split())) for _ in range(n)]
P = [list(map(int, input().split()))[:(F[n_i]+1)] for n_i in range(n)]

ans = 0
all_entry_zero = True

for p_i in P:
  
  ans += max(p_i)
  if max(p_i) in p_i[1:]:
    all_entry_zero = False

if all_entry_zero:
  ans = max(list(max(p_i[1:]) for p_i in P))
  
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
f=[0]*n
for i in range(n):
  x=list(map(int,input().split()))
  for j in range(len(x)):
    if x[j]==1:
      f[i]+=1<<j
  
p=[[0 for j in range(10)] for i in range(n)]

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

ans=10**8*(-1)-1
for i in range(1,2**10):
  pro=0
  for j in range(len(f)):
    open=0
    for k in range(10):
      if (i>>k)&1==1 and (f[j]>>k)&1==1:
        open+=1
    pro+=p[j][open]
  if ans<pro:
    ans=pro
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
F= [list(map(int,input().split())) for i in range(n)]
#F[i][j]はi行目、すなわち店i+1の時間帯jに対してやっているかどうか
P= [list(map(int,input().split())) for i in range(n)]
#P[i][j]は店i+1が時間jに1で自分も1の時に得られる効果
ans=[]
for k in range(n):
    for i in range(2**10):
        c=0
        for j in range(10):
            if ((i>>j)&1) and F[k][j]==1:
                c+=1
        ans.append(P[k][c])
print(max(ans))

Submission status: Wrong Answer

Solution code:
import numpy as np
from itertools import product

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

# print(n, f, p)

allcase = np.array(list(product([0, 1], repeat=10)), dtype=bool)

# print(allcase, allcase.shape)

ans = -(10 ** 7) - 10000

for a in allcase:
    if sum(a) == 0:
        # print(a)
        continue
    profit = 0
    for shop in range(n):
        # idx = np.count_nonzero(np.logical_and(f[shop], a))
        idx = np.count_nonzero(np.logical_and(f[shop], a))

        profit += p[shop][idx]
    ans = max(ans, profit)

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
from itertools import product

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

# print(n, f, p)

allcase = np.array(list(product([0, 1], repeat=10)), dtype=bool)

# print(allcase, allcase.shape)

ans = -(10 ** 7) - 100

for a in allcase:
    if sum(a) == 0:
        # print(a)
        continue
    profit = 0
    for shop in range(n):
        # idx = np.count_nonzero(np.logical_and(f[shop], a))
        idx = np.count_nonzero(np.logical_and(f[shop], a))

        profit += p[shop][idx]
    ans = max(ans, profit)

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
from itertools import product

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

# print(n, f, p)

allcase = np.array(list(product([0, 1], repeat=10)), dtype=bool)

# print(allcase, allcase.shape)

ans = -(10 ** 7)

for a in allcase:
    if sum(a) == 0:
        # print(a)
        continue
    profit = 0
    for shop in range(n):
        idx = np.count_nonzero(np.logical_and(f[shop], a))
        profit += p[shop][idx]
    ans = max(ans, profit)

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

ans=-10**8
for k in range(1,1<<10):
    op=[k>>j&1 for j in range(10)]
    res=0
    for i in range(N):
        c=sum([F[i][j]&op[j] for j in range(10)])
        res+=P[i][c]
    ans=max(ans,res)

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

ans = -(10**8)
for i in range(2**10):
    one_or_zero = [0] * 10
    for j in range(10):
        if ((i >> j) & 1):
            one_or_zero[10 - 1 - j] = 1
    if 1 not in one_or_zero:
        pass
    else:
        tmp_ans = 0
        for m in range(N):
            count = 0
            for k in range(10):
                if F[m][k] == 1 and one_or_zero[k] == 1:
                    count += 1
            tmp_ans += P[m][count]
        if tmp_ans > ans:
            ans = tmp_ans

print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
F=[[int(s) for s in input().split()] for i in range(N)]
P=[[int(s) for s in input().split()] for i in range(N)]
def bi(num):
  val_ls=[0 for _ in range(10)]
  for bi_i in range(10):
    if (2**bi_i)&num>0:
      val_ls[bi_i]=1
  return val_ls
def ri(bi_ls):
  val_ri=0
  for ri_i in range(N):
    val=0
    for j in range(10):
      if bi_ls[j]==F[ri_i][j] and bi_ls[j]==1:
        val+=1
    val_ri+=P[ri_i][val]
  return val_ri
print(max([ri(bi(i)) for i in range(1,1023)]))

Submission status: Wrong Answer

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

ans = -float('inf')
for i in range(1,2**10):
  sum = 0
  for idx, j in enumerate(F):
    bin_num = int("".join(j), 2)
    num = bin(i & bin_num)[2:].count('1')
    sum += P[idx][num]
    if (sum > ans):
      ans = sum
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())))
ans = 0
max_lst = []
for i,f in enumerate(F):
  num = max(P[i][:sum(F[i])+1])
  if (num > 0):
    ans += num
  else:
    max_lst.append(max(P[i][1:sum(F[i])+1]))
if (ans == 0):
  ans = max(max_lst)
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
from collections import defaultdict
D = defaultdict(int)
for e in A:
    D[e] += 1
l1 = []
l2 = []
for key,value in D.items():
    if value > 1:
        l1.append(key)
    if value > 3:
        l2.append(key)
if len(l1) < 2:
    print(0)
    exit()
l1.sort()
l2.sort()
print(max(l1[-1]*l1[-2],l2[-1]*l2[-1]))

Submission status: Wrong Answer

Solution code:
# ABC080 C - Shopping Street
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
n=ni()
f=[nl() for _ in range(n)]
p=[nl() for _ in range(n)]
o = []
ans = -10**8
for i in range(2**10):
    op = [0]*10
    for j in range(10):
        if ((i>>j)&1):
            op[10-1-j]=1
    if not any(op):
        continue
    else:
        o.append(op)

for oo in o:
    value = 0
    for i,ff in enumerate(f):
        t=0
        for j in range(10):
            if oo[j]==1 and ff[j]==1:
                t+=1
        value += p[i][t]
    ans = max(ans,value)

print(ans)

Submission status: Wrong Answer

Solution code:

N=int(input())
F=[int(input().replace(' ','')) for i in range(N)]
P=[list(map(int,input().split())) for i in range(N)]
print(max(sum([p[bin(f&i).count('1')] for f,p in zip(F,P)]) for i in range(1,2**10)))

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

stk.append([0] * N)

for i in range(10):
    len_stk = len(stk)
    for j in range(len_stk):
        total = 0
        arr = []
        is_opened = False
        for k in range(N):
            if f[k][i] == 1:
                is_opened = True

        if is_opened:
            for k in range(N):
                open_cnt = stk[j][k] + f[k][i]
                arr.append(open_cnt)
                total += p[k][open_cnt]
            ans = max(ans, total)
            stk.append(arr)

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

ans = -(10 ** 7)
stk = []

stk.append([0] * N)

for i in range(10):
    len_stk = len(stk)
    for j in range(len_stk):
        total = 0
        arr = []
        is_opened = False
        for k in range(N):
            if f[k][i] == 1:
                is_opened = True
            open_cnt = stk[j][k] + f[k][i]
            arr.append(open_cnt)
            total += p[k][open_cnt]
        if is_opened:
            ans = max(ans, total)
            stk.append(arr)

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

ans = -(10 ** 7)
stk = []

total = 0
stk.append([0] * N)

for i in range(10):
    len_stk = len(stk)
    for j in range(len_stk):
        total = 0
        arr = []
        is_opened = False
        for k in range(N):
            if f[k][i] == 1:
                is_opened = True
            open_cnt = stk[j][k] + f[k][i]
            arr.append(open_cnt)
            total += p[k][open_cnt]
        if is_opened:
            ans = max(ans, total)
        stk.append(arr)

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

ans = -(10 ** 7)
stk = []

total = 0
stk.append([0] * N)

for i in range(10):
    len_stk = len(stk)
    for j in range(len_stk):
        total = 0
        arr = []
        is_opened = False
        for k in range(N):
            if f[k][i] == 1:
                is_opened = 1
            open_cnt = stk[j][k] + f[k][i]
            arr.append(open_cnt)
            total += p[k][open_cnt]
        if is_opened:
            ans = max(ans, total)
        stk.append(arr)

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

ans = -(10 ** 7)
stk = []

stk.append([0] * N)

for i in range(10):
    len_stk = len(stk)
    for j in range(len_stk):
        total = 0
        arr = []
        for k in range(N):
            open_cnt = stk[j][k] + f[k][i]
            arr.append(open_cnt)
            total += p[k][open_cnt]
        ans = max(ans, total)
        stk.append(arr)

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

ans = -(10 ** 7)
stk = []

for i in range(N):
    ans += p[i][0]
stk.append([0] * N)

for i in range(10):
    len_stk = len(stk)
    for j in range(len_stk):
        total = 0
        arr = []
        for k in range(N):
            open_cnt = stk[j][k] + f[k][i]
            arr.append(open_cnt)
            total += p[k][open_cnt]
        ans = max(ans, total)
        stk.append(arr)

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) ]
J = [0 for i in range(10)]
Ben = - (10**8)

for n in range(1,2**10):
  J = list(format(n, 'b'))
  b=0
  for k in range(N):
    c=0
    for ij in range(len(J)):
      if J[ij]=="1" and F[k][ij]==1:
        c+=1
    b += P[k][c]
  if b>Ben:
    Ben=b

print(Ben)

Submission status: Wrong Answer

Solution code:
#C
from collections import deque
import bisect
import math
import heapq
import itertools
import sys
input = sys.stdin.readline

inf = float("inf")
mod = 10**9 + 7
#mod = 998244353

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

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 = -inf
for i in range(1023):
    if i == 0:
        continue
    b = bin(i)
    b = b.lstrip("0b")
    while len(b) < 10:
        b = "0"+b
    
    kari = 0
    for j in range(N):
        f = F[j]
        p = P[j]
        C = 0
        for k in range(10):
            if b[k] == "1" and f[k] == 1:
                C+=1
        kari += p[C]
    ans = max(ans,kari)    
print(ans)

Submission status: Wrong Answer

Solution code:
#C
from collections import deque
import bisect
import math
import heapq
import itertools
import sys
input = sys.stdin.readline

inf = float("inf")
mod = 10**9 + 7
#mod = 998244353

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

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

ite = [i for i in range(10)]

ans = []
for i in range(1023):
    if i == 0:
        continue
    b = bin(i)
    b = b.lstrip("0b")
    while len(b) < 10:
        b = "0"+b
    
    kari = 0
    for j in range(N):
        f = F[j]
        p = P[j]
        C = 0
        for k in range(10):
            if b[k] == "1" and f[k] == 1:
                C+=1
        kari += p[C]
    ans.append(kari)
    
print(max(ans))

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
import sys
import bisect
import math
import itertools
import string
import queue
import copy
# import numpy as np
# import scipy
from itertools import permutations, combinations
from heapq import heappop, heappush
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
 
def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return [list(map(int, input().split())) for _ in range(n)]

def main():
    n=inp()
    f=[]
    for _ in range(n):
        f.append(sum(inpl()))
    p=[]
    for _ in range(n):
        p.append(inpl())
    ans=0
    play=[]
    for i in range(n):
        m=0
        M=0
        for j in range(f[i]+1):
            if m<p[i][j]:
                m,M=p[i][j],j
        ans+=m
        play.append(M)
    if play==[0 for _ in range(n)]:
        least = -10**8
        for i in range(n):
            for j in range(1,f[i]+1):
                least=max(least,p[i][j])
        ans+=least
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n=int(input())
s=[]
k=[]
ans=0
qw=-999999999999999999
for i in range(n):
  a=list(map(int,input().split()))
  s.append(a)
for j in range(n):
  b=list(map(int,input().split()))
  k.append(b)
for i in range(n):
  for j in range(10):
    if s[i][j]==1 and k[i][j]>0:
      ans+=k[i][j]
    elif s[i][j]==1 and k[i][j]<0:
      qw=max(qw,k[i][j])
if ans>0:
  print(ans)
else:
  print(qw)

Submission status: Wrong Answer

Solution code:
from sys import stdin

n = int(stdin.readline().rstrip())
f = [list(map(int,stdin.readline().rstrip().split())) for _ in range(n)]
p = [list(map(int,stdin.readline().rstrip().split())) for _ in range(n+1)]

def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

ma = -1*(10**8)
for i in range(1,1024):
    s = Base_10_to_n(i,2).zfill(10)
    total = 0
    for j in range(n):
        point = 0
        for k in range(10):
            if int(s[k]) == 1 and f[j][k] == 1:
                point += 1
        total += p[j][point]
    ma = max(ma,total)
    
print(ma)

Submission status: Wrong Answer

Solution code:
from sys import stdin

n = int(stdin.readline().rstrip())
f = [list(map(int,stdin.readline().rstrip().split())) for _ in range(n)]
p = [list(map(int,stdin.readline().rstrip().split())) for _ in range(n+1)]

def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

ma = 0
for i in range(1,1024):
    s = Base_10_to_n(i,2).zfill(10)
    total = 0
    for j in range(n):
        point = 0
        for k in range(10):
            if int(s[k]) == 1 and f[j][k] == 1:
                point += 1
        total += p[j][point]
    ma = max(ma,total)
    
print(ma)

Submission status: Wrong Answer

Solution code:
import sys
input=sys.stdin.readline
N=int(input())
F=[int(input().replace(' ',''),2) for _ in range(N)]
P=[list(map(int,input().split())) for _ in range(N)]

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

Submission status: Wrong Answer

Solution code:
import sys
import itertools

# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics


# bit を使ってci を管理する

def toBit(n): 
    return eval('0b' + n)

def main():

    n = int(sys.stdin.readline().rstrip())

    schedule = [toBit(''.join(str(x) for x in sys.stdin.readline().split())) for _ in range(n)]
    profit_table = [[int(x) for x in sys.stdin.readline().split()] for _ in range(n)]

    maximum_profit = -10**10
    for open_pattern in itertools.product('01', repeat=10):
        open_pattern = toBit(''.join(open_pattern))
        if open_pattern == '0b0':
            continue
        profit = 0
        for i in range(n):
            checked = schedule[i]
            number_of_periods = bin(checked & open_pattern).count('1')
            profit += profit_table[i][number_of_periods]
        maximum_profit = max(maximum_profit, profit)

    print(maximum_profit)

if __name__ == "__main__":
    # execute only if run as a script
    main()