結果

問題 No.3046 yukicoderの過去問
ユーザー sannennemutarousannennemutarou
提出日時 2021-02-09 23:37:46
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 720 bytes
コンパイル時間 1,798 ms
コンパイル使用メモリ 168,612 KB
実行使用メモリ 8,756 KB
最終ジャッジ日時 2023-09-21 11:09:15
合計ジャッジ時間 6,345 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
8,756 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 3 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 3 ms
4,376 KB
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main()
{
    int K, N;
    cin >> K >> N;
    vector<int>steps(N);
    for (int i=0; i<N; i++) {
        cin >> steps.at(i);
    }

    vector<int64_t>dp(K+1);
    dp[0] = 1;
    for (int i=0; i<=K; i++) {
        for (int j=0; j<N; j++) {
            if (i+steps[j]<=K) {
                dp[i+steps[j]] += dp[i];
                dp[i+steps[j]] %= 1000000007;
            }
        }
    }

    cout << dp[K] << endl;
    return 0;
}
0