結果

問題 No.1360 [Zelkova 4th Tune] 協和音
ユーザー tktk_snsntktk_snsn
提出日時 2021-01-22 21:33:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 471 ms / 2,000 ms
コード長 606 bytes
コンパイル時間 299 ms
コンパイル使用メモリ 87,084 KB
実行使用メモリ 77,308 KB
最終ジャッジ日時 2023-08-27 17:44:12
合計ジャッジ時間 15,715 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,308 KB
testcase_01 AC 76 ms
71,204 KB
testcase_02 AC 77 ms
71,120 KB
testcase_03 AC 76 ms
71,324 KB
testcase_04 AC 76 ms
71,232 KB
testcase_05 AC 77 ms
71,392 KB
testcase_06 AC 76 ms
71,336 KB
testcase_07 AC 77 ms
71,304 KB
testcase_08 AC 78 ms
71,272 KB
testcase_09 AC 76 ms
71,264 KB
testcase_10 AC 76 ms
71,100 KB
testcase_11 AC 76 ms
71,352 KB
testcase_12 AC 80 ms
71,268 KB
testcase_13 AC 79 ms
71,112 KB
testcase_14 AC 89 ms
76,372 KB
testcase_15 AC 88 ms
76,616 KB
testcase_16 AC 83 ms
75,696 KB
testcase_17 AC 88 ms
76,656 KB
testcase_18 AC 77 ms
71,332 KB
testcase_19 AC 94 ms
76,604 KB
testcase_20 AC 88 ms
76,644 KB
testcase_21 AC 77 ms
71,260 KB
testcase_22 AC 93 ms
76,656 KB
testcase_23 AC 121 ms
77,308 KB
testcase_24 AC 149 ms
77,104 KB
testcase_25 AC 471 ms
77,148 KB
testcase_26 AC 94 ms
76,528 KB
testcase_27 AC 92 ms
76,688 KB
testcase_28 AC 464 ms
77,196 KB
testcase_29 AC 106 ms
76,532 KB
testcase_30 AC 123 ms
77,088 KB
testcase_31 AC 123 ms
77,088 KB
testcase_32 AC 98 ms
76,408 KB
testcase_33 AC 465 ms
77,300 KB
testcase_34 AC 468 ms
77,044 KB
testcase_35 AC 463 ms
77,052 KB
testcase_36 AC 467 ms
76,936 KB
testcase_37 AC 466 ms
77,124 KB
testcase_38 AC 464 ms
76,932 KB
testcase_39 AC 462 ms
77,024 KB
testcase_40 AC 465 ms
77,184 KB
testcase_41 AC 462 ms
77,128 KB
testcase_42 AC 461 ms
77,176 KB
testcase_43 AC 75 ms
71,536 KB
testcase_44 AC 457 ms
77,172 KB
testcase_45 AC 75 ms
71,304 KB
testcase_46 AC 450 ms
76,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

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

ans = -1
pair = -1
for S in range(1, 1 << N):
    score = 0
    for i, a in enumerate(A):
        if (S >> i) & 1:
            score += a
    for i in range(N):
        if (S >> i) & 1:
            for j in range(i + 1, N):
                if (S >> j) & 1:
                    score += B[i][j]
    if score > ans:
        ans = score
        pair = S

print(ans)
print(*[i+1 for i in range(N) if (pair >> i) & 1])
0