結果

問題 No.1360 [Zelkova 4th Tune] 協和音
ユーザー c-yanc-yan
提出日時 2021-01-22 21:44:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 624 ms / 2,000 ms
コード長 558 bytes
コンパイル時間 1,932 ms
コンパイル使用メモリ 86,524 KB
実行使用メモリ 77,364 KB
最終ジャッジ日時 2023-08-27 18:23:27
合計ジャッジ時間 17,918 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,296 KB
testcase_01 AC 69 ms
71,360 KB
testcase_02 AC 70 ms
71,108 KB
testcase_03 AC 71 ms
71,108 KB
testcase_04 AC 67 ms
71,260 KB
testcase_05 AC 69 ms
71,336 KB
testcase_06 AC 69 ms
71,480 KB
testcase_07 AC 69 ms
71,444 KB
testcase_08 AC 68 ms
71,308 KB
testcase_09 AC 68 ms
71,384 KB
testcase_10 AC 71 ms
71,152 KB
testcase_11 AC 70 ms
71,160 KB
testcase_12 AC 71 ms
71,368 KB
testcase_13 AC 72 ms
71,288 KB
testcase_14 AC 86 ms
76,368 KB
testcase_15 AC 81 ms
76,280 KB
testcase_16 AC 79 ms
76,000 KB
testcase_17 AC 81 ms
76,436 KB
testcase_18 AC 71 ms
71,404 KB
testcase_19 AC 89 ms
76,544 KB
testcase_20 AC 82 ms
76,392 KB
testcase_21 AC 70 ms
71,324 KB
testcase_22 AC 85 ms
76,352 KB
testcase_23 AC 153 ms
77,100 KB
testcase_24 AC 187 ms
77,344 KB
testcase_25 AC 572 ms
77,280 KB
testcase_26 AC 91 ms
76,444 KB
testcase_27 AC 91 ms
76,340 KB
testcase_28 AC 568 ms
77,084 KB
testcase_29 AC 108 ms
76,924 KB
testcase_30 AC 152 ms
77,080 KB
testcase_31 AC 152 ms
77,112 KB
testcase_32 AC 96 ms
76,708 KB
testcase_33 AC 564 ms
76,704 KB
testcase_34 AC 574 ms
76,948 KB
testcase_35 AC 624 ms
77,068 KB
testcase_36 AC 560 ms
77,256 KB
testcase_37 AC 619 ms
77,068 KB
testcase_38 AC 567 ms
77,080 KB
testcase_39 AC 558 ms
76,992 KB
testcase_40 AC 572 ms
77,364 KB
testcase_41 AC 561 ms
76,968 KB
testcase_42 AC 571 ms
76,692 KB
testcase_43 AC 68 ms
70,968 KB
testcase_44 AC 562 ms
76,860 KB
testcase_45 AC 68 ms
71,412 KB
testcase_46 AC 555 ms
76,992 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