結果

問題 No.634 硬貨の枚数1
ユーザー brthyyjp
提出日時 2021-03-17 07:19:13
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 316 bytes
コンパイル時間 152 ms
コンパイル使用メモリ 82,252 KB
実行使用メモリ 70,372 KB
最終ジャッジ日時 2024-11-14 04:51:45
合計ジャッジ時間 6,610 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 9 WA * 66
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
from collections import defaultdict
INF = 10**18
dp = defaultdict(lambda:INF)
dp[0] = 0
for i in reversed(range(1, 5000)):
    nx = defaultdict(lambda: INF)
    a = i*(i+1)//2
    for k, v in dp.items():
        q, r = divmod(n-k, a)
        nx[a*q+k] = min(nx[a*q+k], v+q)
    dp = nx
print(dp[n])
0