結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
71,204 KB
testcase_01 AC 69 ms
71,500 KB
testcase_02 AC 63 ms
71,348 KB
testcase_03 AC 63 ms
71,376 KB
testcase_04 AC 62 ms
71,140 KB
testcase_05 AC 64 ms
71,136 KB
testcase_06 AC 63 ms
71,224 KB
testcase_07 AC 63 ms
71,248 KB
testcase_08 AC 62 ms
71,344 KB
testcase_09 AC 63 ms
71,368 KB
testcase_10 AC 65 ms
71,396 KB
testcase_11 AC 64 ms
71,312 KB
testcase_12 AC 63 ms
71,400 KB
testcase_13 AC 66 ms
71,264 KB
testcase_14 AC 76 ms
76,660 KB
testcase_15 AC 79 ms
76,356 KB
testcase_16 AC 71 ms
76,260 KB
testcase_17 AC 73 ms
76,520 KB
testcase_18 AC 62 ms
71,360 KB
testcase_19 AC 77 ms
76,376 KB
testcase_20 AC 80 ms
76,648 KB
testcase_21 AC 67 ms
71,396 KB
testcase_22 AC 78 ms
76,904 KB
testcase_23 AC 154 ms
77,536 KB
testcase_24 AC 172 ms
77,152 KB
testcase_25 AC 557 ms
76,964 KB
testcase_26 AC 81 ms
76,800 KB
testcase_27 AC 76 ms
76,660 KB
testcase_28 AC 536 ms
76,856 KB
testcase_29 AC 97 ms
77,204 KB
testcase_30 AC 138 ms
77,284 KB
testcase_31 AC 137 ms
77,200 KB
testcase_32 AC 89 ms
76,932 KB
testcase_33 AC 535 ms
77,172 KB
testcase_34 AC 538 ms
77,028 KB
testcase_35 AC 538 ms
77,160 KB
testcase_36 AC 530 ms
77,092 KB
testcase_37 AC 529 ms
77,324 KB
testcase_38 AC 548 ms
77,348 KB
testcase_39 AC 531 ms
77,172 KB
testcase_40 AC 537 ms
77,028 KB
testcase_41 AC 534 ms
77,188 KB
testcase_42 AC 542 ms
77,200 KB
testcase_43 AC 63 ms
71,408 KB
testcase_44 AC 536 ms
77,220 KB
testcase_45 AC 61 ms
71,032 KB
testcase_46 AC 537 ms
77,184 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=[0]*(N+1)
    Base=0
    for i in range(1,N+1):
        if x&1:
            M[i]=1
            Base+=A[i]
        x>>=1

    Harmony=0
    for i in range(1,N+1):
        for j in range(i+1,N+1):
            if M[i]==M[j]==1:
                Harmony+=B[i][j]

    Score=Base+Harmony
    if Score>Max:
        Max=Score
        Arg=M.copy()

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