結果

問題 No.1360 [Zelkova 4th Tune] 協和音
ユーザー donutholedonuthole
提出日時 2021-01-22 22:38:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 244 ms / 2,000 ms
コード長 1,008 bytes
コンパイル時間 281 ms
コンパイル使用メモリ 86,964 KB
実行使用メモリ 77,812 KB
最終ジャッジ日時 2023-08-27 20:39:39
合計ジャッジ時間 12,259 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
71,544 KB
testcase_01 AC 89 ms
71,864 KB
testcase_02 AC 91 ms
71,664 KB
testcase_03 AC 91 ms
71,716 KB
testcase_04 AC 91 ms
71,952 KB
testcase_05 AC 90 ms
71,796 KB
testcase_06 AC 90 ms
71,720 KB
testcase_07 AC 91 ms
71,948 KB
testcase_08 AC 88 ms
71,620 KB
testcase_09 AC 89 ms
71,620 KB
testcase_10 AC 89 ms
71,784 KB
testcase_11 AC 89 ms
71,444 KB
testcase_12 AC 88 ms
71,816 KB
testcase_13 AC 89 ms
71,716 KB
testcase_14 AC 97 ms
77,360 KB
testcase_15 AC 98 ms
77,584 KB
testcase_16 AC 88 ms
71,508 KB
testcase_17 AC 98 ms
77,228 KB
testcase_18 AC 89 ms
71,676 KB
testcase_19 AC 99 ms
77,280 KB
testcase_20 AC 97 ms
77,448 KB
testcase_21 AC 90 ms
71,604 KB
testcase_22 AC 97 ms
77,504 KB
testcase_23 AC 115 ms
77,572 KB
testcase_24 AC 134 ms
77,812 KB
testcase_25 AC 241 ms
77,196 KB
testcase_26 AC 102 ms
77,464 KB
testcase_27 AC 102 ms
77,488 KB
testcase_28 AC 239 ms
77,552 KB
testcase_29 AC 107 ms
77,552 KB
testcase_30 AC 115 ms
77,692 KB
testcase_31 AC 116 ms
77,472 KB
testcase_32 AC 105 ms
77,476 KB
testcase_33 AC 238 ms
77,136 KB
testcase_34 AC 240 ms
77,600 KB
testcase_35 AC 240 ms
77,616 KB
testcase_36 AC 241 ms
77,388 KB
testcase_37 AC 242 ms
77,492 KB
testcase_38 AC 238 ms
77,592 KB
testcase_39 AC 239 ms
77,460 KB
testcase_40 AC 243 ms
77,616 KB
testcase_41 AC 239 ms
77,396 KB
testcase_42 AC 244 ms
77,356 KB
testcase_43 AC 90 ms
71,620 KB
testcase_44 AC 241 ms
77,504 KB
testcase_45 AC 91 ms
71,688 KB
testcase_46 AC 241 ms
77,540 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import math
import collections


# sys.setrecursionlimit(10000001)
INF = 10 ** 20
# MOD = 10 ** 9 + 7
MOD = 998244353


def ni(): return int(sys.stdin.buffer.readline())
def ns(): return map(int, sys.stdin.buffer.readline().split())
def na(): return list(map(int, sys.stdin.buffer.readline().split()))
def na1(): return list(map(lambda x: int(x)-1, sys.stdin.buffer.readline().split()))


# ===CODE===
def main():
    n = ni()
    a = na()
    b = [na() for _ in range(n)]

    lim = pow(2, n)
    ans = -INF
    ansc = []
    for i in range(lim):
        v = i
        res = 0
        used = []
        for j in range(n):
            if v >> j & 1:
                res += a[j]
                for ui in used:
                    res += b[j][ui]
                used.append(j)
        if ans < res and len(used) > 0:
            ans = max(ans, res)
            ansc = used
    for i in range(len(ansc)):
        ansc[i] += 1
    print(ans)
    print(*ansc)


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