結果

問題 No.1360 [Zelkova 4th Tune] 協和音
ユーザー 👑 KazunKazun
提出日時 2020-10-18 12:15:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 512 ms / 2,000 ms
コード長 619 bytes
コンパイル時間 237 ms
コンパイル使用メモリ 86,924 KB
実行使用メモリ 92,500 KB
最終ジャッジ日時 2023-08-26 17:52:18
合計ジャッジ時間 14,629 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
71,056 KB
testcase_01 AC 68 ms
71,448 KB
testcase_02 AC 66 ms
71,408 KB
testcase_03 AC 64 ms
71,192 KB
testcase_04 AC 63 ms
71,332 KB
testcase_05 AC 62 ms
71,248 KB
testcase_06 AC 61 ms
71,180 KB
testcase_07 AC 62 ms
71,048 KB
testcase_08 AC 61 ms
71,452 KB
testcase_09 AC 65 ms
71,468 KB
testcase_10 AC 62 ms
71,268 KB
testcase_11 AC 64 ms
71,060 KB
testcase_12 AC 62 ms
71,288 KB
testcase_13 AC 64 ms
70,916 KB
testcase_14 AC 71 ms
76,612 KB
testcase_15 AC 78 ms
76,688 KB
testcase_16 AC 67 ms
76,180 KB
testcase_17 AC 74 ms
76,516 KB
testcase_18 AC 62 ms
71,460 KB
testcase_19 AC 73 ms
76,604 KB
testcase_20 AC 74 ms
76,692 KB
testcase_21 AC 63 ms
71,344 KB
testcase_22 AC 76 ms
76,584 KB
testcase_23 AC 117 ms
77,532 KB
testcase_24 AC 155 ms
77,828 KB
testcase_25 AC 445 ms
81,112 KB
testcase_26 AC 94 ms
77,148 KB
testcase_27 AC 79 ms
76,532 KB
testcase_28 AC 453 ms
81,008 KB
testcase_29 AC 95 ms
77,152 KB
testcase_30 AC 113 ms
77,736 KB
testcase_31 AC 112 ms
77,632 KB
testcase_32 AC 93 ms
77,144 KB
testcase_33 AC 512 ms
92,208 KB
testcase_34 AC 501 ms
92,400 KB
testcase_35 AC 497 ms
92,496 KB
testcase_36 AC 507 ms
92,276 KB
testcase_37 AC 498 ms
92,500 KB
testcase_38 AC 504 ms
92,068 KB
testcase_39 AC 501 ms
91,984 KB
testcase_40 AC 504 ms
92,456 KB
testcase_41 AC 503 ms
92,332 KB
testcase_42 AC 511 ms
92,304 KB
testcase_43 AC 64 ms
71,480 KB
testcase_44 AC 427 ms
81,080 KB
testcase_45 AC 66 ms
71,348 KB
testcase_46 AC 453 ms
80,920 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

inf=float("inf")
DP=[-inf]*(1<<N)
DP[0]=0
Max=-float("inf")

for x in range(1<<N):
    y=x
    M=set()
    for i in range(N):
        if y&1:
            M.add(i)
        y>>=1

    for i in range(N):
        C=0
        if i not in M:
            for j in M:
                C+=B[i][j]

            DP[x|(1<<i)]=DP[x]+A[i]+C

DP[0]=-inf
Max=-inf
Arg=0

for x in range(1<<N):
    if DP[x]>Max:
        Max=DP[x]
        Arg=x

print(Max)
print(*[i+1 for i in range(N) if Arg&(1<<i)])
0