結果

問題 No.1360 [Zelkova 4th Tune] 協和音
ユーザー titiatitia
提出日時 2021-01-22 21:28:01
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 557 ms / 2,000 ms
コード長 558 bytes
コンパイル時間 255 ms
コンパイル使用メモリ 86,644 KB
実行使用メモリ 77,192 KB
最終ジャッジ日時 2023-08-27 17:26:02
合計ジャッジ時間 16,449 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,080 KB
testcase_01 AC 69 ms
70,892 KB
testcase_02 AC 70 ms
71,184 KB
testcase_03 AC 71 ms
71,132 KB
testcase_04 AC 70 ms
71,124 KB
testcase_05 AC 72 ms
71,108 KB
testcase_06 AC 71 ms
71,124 KB
testcase_07 AC 70 ms
71,156 KB
testcase_08 AC 69 ms
70,968 KB
testcase_09 AC 71 ms
71,132 KB
testcase_10 AC 72 ms
71,056 KB
testcase_11 AC 71 ms
71,128 KB
testcase_12 AC 70 ms
70,960 KB
testcase_13 AC 72 ms
71,168 KB
testcase_14 AC 89 ms
75,988 KB
testcase_15 AC 83 ms
76,228 KB
testcase_16 AC 79 ms
76,100 KB
testcase_17 AC 81 ms
76,372 KB
testcase_18 AC 71 ms
71,156 KB
testcase_19 AC 89 ms
76,216 KB
testcase_20 AC 84 ms
76,096 KB
testcase_21 AC 70 ms
71,156 KB
testcase_22 AC 88 ms
76,316 KB
testcase_23 AC 147 ms
76,792 KB
testcase_24 AC 182 ms
76,680 KB
testcase_25 AC 557 ms
76,720 KB
testcase_26 AC 89 ms
76,584 KB
testcase_27 AC 87 ms
76,600 KB
testcase_28 AC 554 ms
76,760 KB
testcase_29 AC 109 ms
76,676 KB
testcase_30 AC 147 ms
77,192 KB
testcase_31 AC 145 ms
76,628 KB
testcase_32 AC 95 ms
76,452 KB
testcase_33 AC 553 ms
76,848 KB
testcase_34 AC 548 ms
76,748 KB
testcase_35 AC 553 ms
76,660 KB
testcase_36 AC 550 ms
76,748 KB
testcase_37 AC 550 ms
76,708 KB
testcase_38 AC 552 ms
76,712 KB
testcase_39 AC 548 ms
76,448 KB
testcase_40 AC 555 ms
77,060 KB
testcase_41 AC 549 ms
76,752 KB
testcase_42 AC 551 ms
76,564 KB
testcase_43 AC 69 ms
71,216 KB
testcase_44 AC 545 ms
76,732 KB
testcase_45 AC 69 ms
70,956 KB
testcase_46 AC 553 ms
76,760 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

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

ANS=-1<<100
ANSIND=[]

for i in range(1,1<<N):
    LIST=[0]*N
    S=0
    for j in range(N):
        if (1<<j) & i !=0:
            LIST[j]=1
            S+=A[j]

    for j in range(N):
        for k in range(j+1,N):
            if LIST[j]==1 and LIST[k]==1:
                S+=B[j][k]

    if ANS<S:
        ANS=S
        ANSIND=[i+1 for i in range(N) if LIST[i]==1]

print(ANS)
print(*ANSIND)
                
    
0