結果

問題 No.1360 [Zelkova 4th Tune] 協和音
ユーザー c-yanc-yan
提出日時 2021-01-22 21:41:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 608 ms / 2,000 ms
コード長 577 bytes
コンパイル時間 386 ms
コンパイル使用メモリ 87,224 KB
実行使用メモリ 77,504 KB
最終ジャッジ日時 2023-08-27 18:11:55
合計ジャッジ時間 16,966 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,400 KB
testcase_01 AC 74 ms
71,212 KB
testcase_02 AC 71 ms
71,380 KB
testcase_03 AC 74 ms
71,488 KB
testcase_04 AC 73 ms
71,536 KB
testcase_05 AC 72 ms
71,388 KB
testcase_06 AC 74 ms
71,392 KB
testcase_07 AC 76 ms
71,320 KB
testcase_08 AC 73 ms
71,368 KB
testcase_09 AC 74 ms
71,476 KB
testcase_10 AC 75 ms
71,484 KB
testcase_11 AC 75 ms
71,404 KB
testcase_12 AC 76 ms
71,448 KB
testcase_13 AC 75 ms
71,364 KB
testcase_14 AC 86 ms
76,764 KB
testcase_15 AC 88 ms
76,696 KB
testcase_16 AC 83 ms
76,464 KB
testcase_17 AC 87 ms
76,604 KB
testcase_18 AC 77 ms
71,368 KB
testcase_19 AC 89 ms
76,364 KB
testcase_20 AC 84 ms
76,492 KB
testcase_21 AC 75 ms
71,212 KB
testcase_22 AC 87 ms
76,660 KB
testcase_23 AC 154 ms
77,504 KB
testcase_24 AC 183 ms
77,008 KB
testcase_25 AC 552 ms
77,156 KB
testcase_26 AC 91 ms
76,628 KB
testcase_27 AC 90 ms
76,568 KB
testcase_28 AC 536 ms
77,020 KB
testcase_29 AC 109 ms
76,984 KB
testcase_30 AC 152 ms
77,020 KB
testcase_31 AC 153 ms
77,248 KB
testcase_32 AC 97 ms
76,744 KB
testcase_33 AC 534 ms
76,812 KB
testcase_34 AC 546 ms
76,872 KB
testcase_35 AC 608 ms
77,164 KB
testcase_36 AC 539 ms
76,996 KB
testcase_37 AC 604 ms
76,992 KB
testcase_38 AC 532 ms
77,064 KB
testcase_39 AC 536 ms
77,064 KB
testcase_40 AC 533 ms
77,060 KB
testcase_41 AC 547 ms
77,240 KB
testcase_42 AC 549 ms
77,120 KB
testcase_43 AC 74 ms
71,056 KB
testcase_44 AC 527 ms
77,152 KB
testcase_45 AC 75 ms
71,480 KB
testcase_46 AC 538 ms
76,868 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)]

result = -(10 ** 18)
for t in product(range(2), repeat=N):
    v = 0
    n = 0
    for i in range(N):
        n += t[i]
        if t[i] == 1:
            v += A[i]
    if n == 0:
        continue
    for i in range(N):
        for j in range(i + 1, N):
            if t[i] & t[j] == 1:
                v += B[i][j]
    if v > result:
        result = v
        max_t = t
print(result)
print(*(i + 1 for i in range(N) if max_t[i] == 1))
0