結果

問題 No.943 取り調べ
ユーザー tanon710tanon710
提出日時 2020-05-04 21:57:13
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 713 bytes
コンパイル時間 1,080 ms
コンパイル使用メモリ 87,284 KB
実行使用メモリ 77,816 KB
最終ジャッジ日時 2023-09-07 06:16:21
合計ジャッジ時間 12,815 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,352 KB
testcase_01 AC 75 ms
71,348 KB
testcase_02 AC 77 ms
71,360 KB
testcase_03 AC 74 ms
71,376 KB
testcase_04 TLE -
testcase_05 TLE -
testcase_06 TLE -
testcase_07 AC 74 ms
71,268 KB
testcase_08 TLE -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 76 ms
71,376 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
check=[list(map(int,input().split())) for _ in range(n)]
for i in range(n):
    tmp=0
    for j in range(n):
        if check[i][j]==1:
            tmp+=2**(n-1-j)
    check[i]=tmp
cost=list(map(int,input().split()))
ans=10**18
for i in range(0,2**n):
    flag=format(i,'b')
    s=set()
    for j in range(len(flag)):
        if flag[-(j+1)]=='1':
            s.add(n-1-j)
    for _ in range(n):
        for j in range(n):
            if j in s:
                continue
            if (~i)&check[j]==0:
                s.add(j)
    if len(s)==n:
        tmp=0
        for j in range(len(flag)):
            if flag[-(j+1)]=='1':
                tmp+=cost[n-1-j]
        ans=min(ans,tmp)
print(ans)
0