結果
問題 |
No.634 硬貨の枚数1
|
ユーザー |
|
提出日時 | 2018-01-19 22:07:45 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 489 bytes |
コンパイル時間 | 699 ms |
コンパイル使用メモリ | 66,304 KB |
実行使用メモリ | 600,960 KB |
最終ジャッジ日時 | 2024-12-25 18:59:35 |
合計ジャッジ時間 | 142,558 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 TLE * 41 MLE * 9 |
ソースコード
#include <iostream> #include <algorithm> using namespace std; int dp[10000001]; int choose(int now){ if(dp[now] != -1){ return dp[now]; }else if(now){ int ans = 1e9; for(int i = 1; i * (i + 1) / 2 <= now; i++){ ans = min(ans, choose(now - i * (i + 1) / 2)); } return dp[now] = ans + 1; }else{ return 0; } } int main(){ int N; cin >> N; fill(dp, dp + 10000001, -1); cout << choose(N) << endl; }