結果

問題 No.115 遠足のおやつ
ユーザー brthyyjp
提出日時 2021-12-10 20:27:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 165 ms / 5,000 ms
コード長 574 bytes
コンパイル時間 158 ms
コンパイル使用メモリ 82,256 KB
実行使用メモリ 79,436 KB
最終ジャッジ日時 2024-07-18 14:29:59
合計ジャッジ時間 4,526 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 40
権限があれば一括ダウンロードができます

ソースコード

diff #

n, d, k = map(int, input().split())
dp = [[-1]*(d+1) for i in range(k+1)]
dp[0][0] = tuple([])
for i in range(1, n+1):
    for j in reversed(range(k+1)):
        for l in reversed(range(d+1)):
            if dp[j][l] == -1:
                continue
            if j+1 <= k and l+i <= d:
                nt = list(dp[j][l])+[i]
                nt = tuple(nt)
                if dp[j+1][l+i] != -1:
                    dp[j+1][l+i] = min(dp[j+1][l+i], nt)
                else:
                    dp[j+1][l+i] = nt
if dp[k][d] != -1:
    print(*dp[k][d])
else:
    print(-1)
0