結果

問題 No.1360 [Zelkova 4th Tune] 協和音
ユーザー 萩3萩3
提出日時 2021-04-30 22:58:00
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 596 ms / 2,000 ms
コード長 842 bytes
コンパイル時間 441 ms
コンパイル使用メモリ 87,244 KB
実行使用メモリ 79,308 KB
最終ジャッジ日時 2023-09-26 07:38:57
合計ジャッジ時間 19,911 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,068 KB
testcase_01 AC 71 ms
71,548 KB
testcase_02 AC 70 ms
71,516 KB
testcase_03 AC 71 ms
71,416 KB
testcase_04 AC 72 ms
71,524 KB
testcase_05 AC 71 ms
71,524 KB
testcase_06 AC 72 ms
71,264 KB
testcase_07 AC 72 ms
71,548 KB
testcase_08 AC 71 ms
71,444 KB
testcase_09 AC 71 ms
71,204 KB
testcase_10 AC 75 ms
71,552 KB
testcase_11 AC 72 ms
71,492 KB
testcase_12 AC 71 ms
71,516 KB
testcase_13 AC 74 ms
75,704 KB
testcase_14 AC 83 ms
76,472 KB
testcase_15 AC 80 ms
76,344 KB
testcase_16 AC 78 ms
76,604 KB
testcase_17 AC 80 ms
76,592 KB
testcase_18 AC 75 ms
75,524 KB
testcase_19 AC 82 ms
76,488 KB
testcase_20 AC 81 ms
76,408 KB
testcase_21 AC 75 ms
75,512 KB
testcase_22 AC 80 ms
76,584 KB
testcase_23 AC 134 ms
77,432 KB
testcase_24 AC 267 ms
77,472 KB
testcase_25 AC 596 ms
79,132 KB
testcase_26 AC 89 ms
76,504 KB
testcase_27 AC 85 ms
76,544 KB
testcase_28 AC 590 ms
79,308 KB
testcase_29 AC 109 ms
77,224 KB
testcase_30 AC 134 ms
77,184 KB
testcase_31 AC 132 ms
77,200 KB
testcase_32 AC 94 ms
77,132 KB
testcase_33 AC 590 ms
79,096 KB
testcase_34 AC 589 ms
78,872 KB
testcase_35 AC 588 ms
79,048 KB
testcase_36 AC 593 ms
78,884 KB
testcase_37 AC 592 ms
78,992 KB
testcase_38 AC 588 ms
79,012 KB
testcase_39 AC 592 ms
79,016 KB
testcase_40 AC 590 ms
79,024 KB
testcase_41 AC 590 ms
79,104 KB
testcase_42 AC 592 ms
79,012 KB
testcase_43 AC 72 ms
71,344 KB
testcase_44 AC 588 ms
79,016 KB
testcase_45 AC 70 ms
71,412 KB
testcase_46 AC 590 ms
78,988 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
def resolve():
    inp = int2d()
    n = inp[0][0]
    scores = inp[1]
    graph = inp[2:]
    dp = [0 for _ in range(1<<n)]
    result = (-1,None)#maxscore, bit

    for bit in range(1<<n):
        for vertex in range(n):
            if not(bit & 1<<vertex): continue
            prebit = bit ^ 1<<vertex

            score = dp[prebit] + scores[vertex]
            for shift in range(n):
                if prebit & 1<<shift:
                    score += graph[shift][vertex]

            dp[bit] = score
            if result[0] < score:
                result = (score, bit)

    l = []
    for i in range(n):
        if result[1] & 1<<i:
            l.append(i+1)

    print(result[0])
    print(*l)
    
def str1d():return sys.stdin.read().splitlines()
def int2d():return [list(map(int,s.split())) for s in str1d()]
resolve()
0