結果

問題 No.1360 [Zelkova 4th Tune] 協和音
ユーザー H3PO4H3PO4
提出日時 2021-01-22 21:41:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 799 ms / 2,000 ms
コード長 474 bytes
コンパイル時間 1,255 ms
コンパイル使用メモリ 86,776 KB
実行使用メモリ 77,268 KB
最終ジャッジ日時 2023-08-27 18:12:59
合計ジャッジ時間 20,819 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,204 KB
testcase_01 AC 73 ms
71,340 KB
testcase_02 AC 73 ms
71,216 KB
testcase_03 AC 71 ms
71,372 KB
testcase_04 AC 72 ms
71,216 KB
testcase_05 AC 71 ms
71,160 KB
testcase_06 AC 71 ms
71,436 KB
testcase_07 AC 73 ms
71,440 KB
testcase_08 AC 72 ms
71,204 KB
testcase_09 AC 70 ms
71,040 KB
testcase_10 AC 71 ms
71,504 KB
testcase_11 AC 72 ms
71,220 KB
testcase_12 AC 72 ms
71,180 KB
testcase_13 AC 72 ms
71,420 KB
testcase_14 AC 80 ms
75,736 KB
testcase_15 AC 75 ms
75,792 KB
testcase_16 AC 69 ms
71,040 KB
testcase_17 AC 73 ms
75,700 KB
testcase_18 AC 71 ms
71,436 KB
testcase_19 AC 86 ms
76,772 KB
testcase_20 AC 76 ms
75,696 KB
testcase_21 AC 75 ms
71,076 KB
testcase_22 AC 83 ms
76,240 KB
testcase_23 AC 152 ms
77,128 KB
testcase_24 AC 233 ms
77,124 KB
testcase_25 AC 799 ms
77,156 KB
testcase_26 AC 89 ms
76,308 KB
testcase_27 AC 84 ms
76,464 KB
testcase_28 AC 794 ms
76,864 KB
testcase_29 AC 114 ms
77,268 KB
testcase_30 AC 152 ms
76,988 KB
testcase_31 AC 152 ms
76,832 KB
testcase_32 AC 98 ms
76,980 KB
testcase_33 AC 797 ms
77,072 KB
testcase_34 AC 788 ms
77,120 KB
testcase_35 AC 795 ms
77,156 KB
testcase_36 AC 793 ms
77,044 KB
testcase_37 AC 791 ms
77,036 KB
testcase_38 AC 793 ms
76,808 KB
testcase_39 AC 792 ms
77,172 KB
testcase_40 AC 795 ms
77,072 KB
testcase_41 AC 797 ms
77,024 KB
testcase_42 AC 795 ms
76,904 KB
testcase_43 AC 71 ms
71,484 KB
testcase_44 AC 798 ms
77,136 KB
testcase_45 AC 71 ms
71,476 KB
testcase_46 AC 796 ms
77,248 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools

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

w = -float('inf')

it = itertools.product((0, 1), repeat=N)
next(it)
for t in it:
    tmp = 0
    comp = list(itertools.compress(range(N), t))
    for x in comp:
        tmp += A[x]
    for x, y in itertools.combinations(comp, 2):
        tmp += B[x][y]
    if w < tmp:
        J = tuple(x + 1 for x in comp)
        w = tmp
print(w)
print(*J)
0