結果
問題 |
No.634 硬貨の枚数1
|
ユーザー |
![]() |
提出日時 | 2021-02-26 03:25:01 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 128 ms / 2,000 ms |
コード長 | 314 bytes |
コンパイル時間 | 183 ms |
コンパイル使用メモリ | 82,380 KB |
実行使用メモリ | 62,976 KB |
最終ジャッジ日時 | 2024-10-01 19:18:18 |
合計ジャッジ時間 | 8,499 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 75 |
ソースコード
n = int(input()) tri = [i*(i+1)//2 for i in range(1,4473)] ans = n def dfs(n,i,cnt): global ans if n == 0: ans = min(ans,cnt) return if ans <= cnt + (n-1)//tri[i]+1: return for j in range(i+1)[::-1]: if n >= tri[j]: dfs(n-tri[j],j,cnt+1) dfs(n,4471,0) print(ans)