結果

問題 No.8046 yukicoderの過去問
ユーザー merom686merom686
提出日時 2019-04-01 21:58:17
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 673 bytes
コンパイル時間 587 ms
コンパイル使用メモリ 73,452 KB
実行使用メモリ 13,636 KB
最終ジャッジ日時 2024-11-26 22:40:46
合計ジャッジ時間 9,267 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 7 TLE * 2
権限があれば一括ダウンロードができます

ソースコード

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