結果

問題 No.3046 yukicoderの過去問
ユーザー merom686merom686
提出日時 2019-04-01 21:58:17
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 673 bytes
コンパイル時間 585 ms
コンパイル使用メモリ 74,532 KB
実行使用メモリ 13,880 KB
最終ジャッジ日時 2024-05-05 04:47:33
合計ジャッジ時間 4,100 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

constexpr int P = 1000000007;

int  x[100000];
int dp[100001];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int k;
    cin >> k;

    int n;
    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> x[i];
    }
    
    dp[0] = 1;
    for (int l = 1; l <= k; l++) {
        ll t = 0;
        for (int i = 0; i < n; i++) {
            if (x[i] > l) break;
            t += dp[l - x[i]];
        }
        dp[l] = t % P;
    }

    cout << dp[k] << endl;

    return 0;
}
0