結果

問題 No.115 遠足のおやつ
ユーザー neko_the_shadow
提出日時 2019-08-05 09:40:10
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 546 bytes
コンパイル時間 156 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 76,800 KB
最終ジャッジ日時 2024-07-18 12:37:32
合計ジャッジ時間 3,495 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24 WA * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

n, d, k = map(int, input().split())

dp = [[None] * (d + 1) for _ in range(k + 1)]
dp[0][0] = (0, )
for x in range(k):
    for y in range(d):
        last = dp[x][y]
        if last is None:
            continue

        for z in range(last[-1] + 1, n + 1):
            if y + z <= d:
                if dp[x + 1][y + z] is None:
                    dp[x + 1][y + z] = (*last, z)
                else:
                    dp[x + 1][y + z] = min(dp[x + 1][y + z], (*last, z))

ans = dp[k][d]
if ans is None:
    print(-1)
else:
    print(*ans[1:])
0