結果

問題 No.1360 [Zelkova 4th Tune] 協和音
ユーザー DrDrpilotDrDrpilot
提出日時 2022-01-30 19:05:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 304 ms / 2,000 ms
コード長 539 bytes
コンパイル時間 559 ms
コンパイル使用メモリ 87,056 KB
実行使用メモリ 77,704 KB
最終ジャッジ日時 2023-09-02 01:46:09
合計ジャッジ時間 12,191 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
71,524 KB
testcase_01 AC 67 ms
71,368 KB
testcase_02 AC 65 ms
71,540 KB
testcase_03 AC 65 ms
71,436 KB
testcase_04 AC 65 ms
71,500 KB
testcase_05 AC 67 ms
71,508 KB
testcase_06 AC 66 ms
71,372 KB
testcase_07 AC 66 ms
71,368 KB
testcase_08 AC 66 ms
71,428 KB
testcase_09 AC 65 ms
71,556 KB
testcase_10 AC 66 ms
71,568 KB
testcase_11 AC 66 ms
71,532 KB
testcase_12 AC 66 ms
71,568 KB
testcase_13 AC 66 ms
71,520 KB
testcase_14 AC 76 ms
76,176 KB
testcase_15 AC 75 ms
76,292 KB
testcase_16 AC 67 ms
71,368 KB
testcase_17 AC 75 ms
76,548 KB
testcase_18 AC 66 ms
71,416 KB
testcase_19 AC 78 ms
76,892 KB
testcase_20 AC 74 ms
76,452 KB
testcase_21 AC 65 ms
71,504 KB
testcase_22 AC 77 ms
76,936 KB
testcase_23 AC 98 ms
77,212 KB
testcase_24 AC 129 ms
77,264 KB
testcase_25 AC 302 ms
77,408 KB
testcase_26 AC 83 ms
76,552 KB
testcase_27 AC 79 ms
76,628 KB
testcase_28 AC 303 ms
77,172 KB
testcase_29 AC 92 ms
77,220 KB
testcase_30 AC 97 ms
77,632 KB
testcase_31 AC 100 ms
77,252 KB
testcase_32 AC 83 ms
76,812 KB
testcase_33 AC 301 ms
77,468 KB
testcase_34 AC 302 ms
77,152 KB
testcase_35 AC 301 ms
77,304 KB
testcase_36 AC 299 ms
77,224 KB
testcase_37 AC 300 ms
77,704 KB
testcase_38 AC 302 ms
77,380 KB
testcase_39 AC 302 ms
77,172 KB
testcase_40 AC 301 ms
77,160 KB
testcase_41 AC 302 ms
77,124 KB
testcase_42 AC 304 ms
77,272 KB
testcase_43 AC 64 ms
71,416 KB
testcase_44 AC 294 ms
77,324 KB
testcase_45 AC 65 ms
71,364 KB
testcase_46 AC 300 ms
77,172 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import product
n=int(input())
a=list(map(int,input().split()))
b=[list(map(int,input().split())) for _ in range(n)]
ans=-10**15
ans_l=[]
for bit in product(range(2),repeat=n):
    tmp=0
    ring=[]
    for i in range(n):
        if bit[i]:
            tmp+=a[i]
            ring.append(i+1)
    if len(ring)>=2:
        for i in range(len(ring)):
            for j in range(i+1,len(ring)):
                tmp+=b[ring[i]-1][ring[j]-1]
    if tmp>=ans:
        ans=tmp
        ans_l=ring
ans_l.sort()
print(ans)
print(*ans_l)
0