結果

問題 No.634 硬貨の枚数1
コンテスト
ユーザー ミドリムシ
提出日時 2018-01-19 22:07:45
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
TLE  
実行時間 -
コード長 489 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 447 ms
コンパイル使用メモリ 76,784 KB
実行使用メモリ 444,160 KB
最終ジャッジ日時 2026-05-31 11:57:36
合計ジャッジ時間 6,407 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12 TLE * 1 -- * 62
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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;
}
0