結果

問題 No.1360 [Zelkova 4th Tune] 協和音
ユーザー 👑 KazunKazun
提出日時 2020-10-18 03:26:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 331 ms / 2,000 ms
コード長 529 bytes
コンパイル時間 250 ms
コンパイル使用メモリ 87,120 KB
実行使用メモリ 77,644 KB
最終ジャッジ日時 2023-08-26 17:51:01
合計ジャッジ時間 14,466 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
71,416 KB
testcase_01 AC 65 ms
71,352 KB
testcase_02 AC 66 ms
71,360 KB
testcase_03 AC 66 ms
71,356 KB
testcase_04 AC 65 ms
71,400 KB
testcase_05 AC 66 ms
71,068 KB
testcase_06 AC 67 ms
71,340 KB
testcase_07 AC 66 ms
71,296 KB
testcase_08 AC 67 ms
71,244 KB
testcase_09 AC 65 ms
71,308 KB
testcase_10 AC 66 ms
71,036 KB
testcase_11 AC 65 ms
71,412 KB
testcase_12 AC 67 ms
71,540 KB
testcase_13 AC 67 ms
71,468 KB
testcase_14 AC 76 ms
76,436 KB
testcase_15 AC 76 ms
76,324 KB
testcase_16 AC 68 ms
71,356 KB
testcase_17 AC 85 ms
76,332 KB
testcase_18 AC 77 ms
71,308 KB
testcase_19 AC 96 ms
76,836 KB
testcase_20 AC 88 ms
76,312 KB
testcase_21 AC 76 ms
71,196 KB
testcase_22 AC 95 ms
76,496 KB
testcase_23 AC 126 ms
77,096 KB
testcase_24 AC 136 ms
77,320 KB
testcase_25 AC 328 ms
77,528 KB
testcase_26 AC 96 ms
77,184 KB
testcase_27 AC 90 ms
77,044 KB
testcase_28 AC 328 ms
77,356 KB
testcase_29 AC 104 ms
77,336 KB
testcase_30 AC 111 ms
77,332 KB
testcase_31 AC 112 ms
77,208 KB
testcase_32 AC 96 ms
77,268 KB
testcase_33 AC 329 ms
77,496 KB
testcase_34 AC 325 ms
77,212 KB
testcase_35 AC 328 ms
77,496 KB
testcase_36 AC 330 ms
77,540 KB
testcase_37 AC 328 ms
77,356 KB
testcase_38 AC 326 ms
77,504 KB
testcase_39 AC 331 ms
77,536 KB
testcase_40 AC 327 ms
77,640 KB
testcase_41 AC 330 ms
77,584 KB
testcase_42 AC 326 ms
77,644 KB
testcase_43 AC 68 ms
71,056 KB
testcase_44 AC 324 ms
77,520 KB
testcase_45 AC 67 ms
71,196 KB
testcase_46 AC 326 ms
77,488 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

Max=-float("inf")
Arg=[]

for x in range(1<<N):
    if x==0:
        continue

    M=[]
    y=x
    for i in range(1,N+1):
        if y%2:
            M.append(i)
        y>>=1

    l=len(M)
    D=0
    for i in range(l):
        for j in range(i+1,l):
            D+=B[M[i]][M[j]]

    Score=sum([A[x] for x in M])+D
    if Score>Max:
        Max=Score
        Arg=M.copy()

print(Max)
print(*Arg)
0