結果

問題 No.115 遠足のおやつ
ユーザー しらっ亭しらっ亭
提出日時 2015-08-22 14:39:50
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 174 ms / 5,000 ms
コード長 682 bytes
コンパイル時間 742 ms
コンパイル使用メモリ 10,844 KB
実行使用メモリ 44,644 KB
最終ジャッジ日時 2023-08-31 00:35:28
合計ジャッジ時間 4,079 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
7,904 KB
testcase_01 AC 14 ms
7,848 KB
testcase_02 AC 15 ms
8,408 KB
testcase_03 AC 14 ms
7,908 KB
testcase_04 AC 137 ms
38,328 KB
testcase_05 AC 13 ms
7,864 KB
testcase_06 AC 13 ms
7,776 KB
testcase_07 AC 16 ms
8,648 KB
testcase_08 AC 14 ms
7,856 KB
testcase_09 AC 13 ms
7,860 KB
testcase_10 AC 14 ms
7,812 KB
testcase_11 AC 13 ms
7,808 KB
testcase_12 AC 15 ms
8,224 KB
testcase_13 AC 14 ms
7,780 KB
testcase_14 AC 17 ms
9,020 KB
testcase_15 AC 70 ms
23,372 KB
testcase_16 AC 145 ms
40,764 KB
testcase_17 AC 103 ms
30,924 KB
testcase_18 AC 48 ms
17,144 KB
testcase_19 AC 53 ms
18,672 KB
testcase_20 AC 19 ms
9,784 KB
testcase_21 AC 14 ms
8,472 KB
testcase_22 AC 37 ms
14,596 KB
testcase_23 AC 14 ms
8,412 KB
testcase_24 AC 32 ms
13,288 KB
testcase_25 AC 164 ms
42,336 KB
testcase_26 AC 29 ms
12,136 KB
testcase_27 AC 29 ms
12,472 KB
testcase_28 AC 21 ms
10,048 KB
testcase_29 AC 39 ms
14,384 KB
testcase_30 AC 32 ms
13,596 KB
testcase_31 AC 23 ms
10,248 KB
testcase_32 AC 96 ms
27,640 KB
testcase_33 AC 25 ms
10,688 KB
testcase_34 AC 122 ms
36,320 KB
testcase_35 AC 34 ms
12,932 KB
testcase_36 AC 28 ms
12,400 KB
testcase_37 AC 106 ms
30,232 KB
testcase_38 AC 174 ms
44,644 KB
testcase_39 AC 173 ms
44,644 KB
testcase_40 AC 13 ms
7,944 KB
testcase_41 AC 13 ms
7,776 KB
testcase_42 AC 13 ms
7,860 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve():
    N, D, K = list(map(int, input().split()))
    D -= K

    dp = [[{} for k in range(K + 2)] for i in range(N + 1)]

    # dp[i][k][d] = i 番目までで k 個買って d 円使う組み合わせ
    dp[0][0][0] = []

    for i in range(N):
        for k in range(K+1):
            for d in dp[i][k]:
                if d not in dp[i + 1][k]:
                    dp[i + 1][k][d] = dp[i][k][d]
                if k < K and d + i not in dp[i + 1][k + 1]:
                    dp[i + 1][k + 1][d + i] = dp[i][k][d] + [i]

    if D in dp[N][K]:
        print(' '.join(str(i + 1) for i in dp[N][K][D]))
    else:
        print(-1)


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