結果

問題 No.1360 [Zelkova 4th Tune] 協和音
ユーザー hiragnhiragn
提出日時 2022-11-24 09:02:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 665 ms / 2,000 ms
コード長 658 bytes
コンパイル時間 166 ms
コンパイル使用メモリ 81,856 KB
実行使用メモリ 75,464 KB
最終ジャッジ日時 2023-10-26 01:03:47
合計ジャッジ時間 15,288 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,596 KB
testcase_01 AC 37 ms
53,596 KB
testcase_02 AC 37 ms
53,596 KB
testcase_03 AC 37 ms
53,596 KB
testcase_04 AC 37 ms
53,596 KB
testcase_05 AC 37 ms
53,596 KB
testcase_06 AC 37 ms
53,596 KB
testcase_07 AC 37 ms
53,596 KB
testcase_08 AC 37 ms
53,596 KB
testcase_09 AC 37 ms
53,596 KB
testcase_10 AC 36 ms
53,596 KB
testcase_11 AC 37 ms
53,596 KB
testcase_12 AC 38 ms
53,596 KB
testcase_13 AC 38 ms
53,596 KB
testcase_14 AC 52 ms
64,268 KB
testcase_15 AC 51 ms
64,268 KB
testcase_16 AC 45 ms
61,940 KB
testcase_17 AC 51 ms
64,268 KB
testcase_18 AC 38 ms
53,596 KB
testcase_19 AC 55 ms
66,336 KB
testcase_20 AC 52 ms
64,268 KB
testcase_21 AC 38 ms
53,596 KB
testcase_22 AC 56 ms
66,336 KB
testcase_23 AC 126 ms
75,392 KB
testcase_24 AC 182 ms
75,460 KB
testcase_25 AC 661 ms
75,460 KB
testcase_26 AC 61 ms
73,312 KB
testcase_27 AC 58 ms
70,440 KB
testcase_28 AC 658 ms
75,456 KB
testcase_29 AC 85 ms
75,464 KB
testcase_30 AC 127 ms
75,388 KB
testcase_31 AC 127 ms
75,392 KB
testcase_32 AC 77 ms
75,452 KB
testcase_33 AC 658 ms
75,464 KB
testcase_34 AC 665 ms
75,460 KB
testcase_35 AC 657 ms
75,460 KB
testcase_36 AC 658 ms
75,464 KB
testcase_37 AC 657 ms
75,460 KB
testcase_38 AC 656 ms
75,460 KB
testcase_39 AC 658 ms
75,464 KB
testcase_40 AC 659 ms
75,464 KB
testcase_41 AC 663 ms
75,460 KB
testcase_42 AC 662 ms
75,460 KB
testcase_43 AC 37 ms
53,596 KB
testcase_44 AC 658 ms
75,452 KB
testcase_45 AC 38 ms
53,596 KB
testcase_46 AC 659 ms
75,456 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = [list(map(int, input().split())) for _ in range(n)]

    inf = 1 << 60
    ans = -inf
    ans_bit = 0
    for bit in range(1, 1 << n):
        res = 0
        for i in range(n):
            if bit & (1 << i):
                res += a[i]
        for i in range(n):
            for j in range(i + 1, n):
                if bit & (1 << i) and bit & (1 << j):
                    res += b[i][j]
        if ans < res:
            ans = res
            ans_bit = bit

    print(ans)
    print(*[i + 1 for i in range(n) if ans_bit & (1 << i)])


if __name__ == "__main__":
    main()
0