結果

問題 No.1360 [Zelkova 4th Tune] 協和音
ユーザー nohakai3nohakai3
提出日時 2022-07-08 17:30:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 636 ms / 2,000 ms
コード長 557 bytes
コンパイル時間 236 ms
コンパイル使用メモリ 87,156 KB
実行使用メモリ 77,540 KB
最終ジャッジ日時 2023-08-27 16:39:26
合計ジャッジ時間 16,107 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
71,440 KB
testcase_01 AC 61 ms
71,236 KB
testcase_02 AC 62 ms
71,440 KB
testcase_03 AC 66 ms
71,244 KB
testcase_04 AC 62 ms
71,592 KB
testcase_05 AC 62 ms
71,232 KB
testcase_06 AC 62 ms
71,396 KB
testcase_07 AC 60 ms
71,444 KB
testcase_08 AC 63 ms
71,440 KB
testcase_09 AC 63 ms
71,532 KB
testcase_10 AC 68 ms
71,444 KB
testcase_11 AC 65 ms
71,436 KB
testcase_12 AC 67 ms
71,428 KB
testcase_13 AC 66 ms
71,232 KB
testcase_14 AC 89 ms
76,560 KB
testcase_15 AC 84 ms
76,740 KB
testcase_16 AC 75 ms
76,484 KB
testcase_17 AC 76 ms
76,572 KB
testcase_18 AC 68 ms
71,456 KB
testcase_19 AC 85 ms
76,532 KB
testcase_20 AC 81 ms
76,396 KB
testcase_21 AC 73 ms
71,484 KB
testcase_22 AC 89 ms
76,708 KB
testcase_23 AC 151 ms
77,316 KB
testcase_24 AC 187 ms
77,248 KB
testcase_25 AC 535 ms
77,216 KB
testcase_26 AC 91 ms
76,396 KB
testcase_27 AC 93 ms
76,596 KB
testcase_28 AC 570 ms
77,164 KB
testcase_29 AC 103 ms
77,264 KB
testcase_30 AC 138 ms
77,312 KB
testcase_31 AC 143 ms
77,312 KB
testcase_32 AC 89 ms
77,148 KB
testcase_33 AC 518 ms
77,256 KB
testcase_34 AC 535 ms
77,340 KB
testcase_35 AC 636 ms
77,272 KB
testcase_36 AC 520 ms
77,168 KB
testcase_37 AC 619 ms
77,236 KB
testcase_38 AC 521 ms
77,540 KB
testcase_39 AC 532 ms
77,296 KB
testcase_40 AC 544 ms
77,224 KB
testcase_41 AC 528 ms
77,336 KB
testcase_42 AC 543 ms
77,212 KB
testcase_43 AC 72 ms
71,532 KB
testcase_44 AC 554 ms
77,228 KB
testcase_45 AC 69 ms
71,456 KB
testcase_46 AC 557 ms
76,864 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)]

W = -(10 ** 18)
for bits in product(range(2), repeat=N):
    if sum(bits) == 0:
        continue
    w = 0
    for i in range(N):
        if bits[i] == 1:
            w += A[i]
    for i in range(N):
        for j in range(i + 1, N):
            if bits[i] & bits[j] == 1:
                w += B[i][j]
    if w > W:
        W = w
        max_bits = bits
print(W)
print(*(i + 1 for i in range(N) if max_bits[i] == 1))
0