結果

問題 No.3046 yukicoderの過去問
ユーザー mikianaaamikianaaa
提出日時 2020-08-23 22:09:48
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 751 bytes
コンパイル時間 1,577 ms
コンパイル使用メモリ 164,868 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-04-23 18:37:10
合計ジャッジ時間 5,334 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ld long double
#define INF 1000000000000000000
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;

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

    ll K, N;
    cin >> K >> N;
    vector<ll> x(N);
    ll MOD = pow(10, 9) + 7;
    rep(i, N) { cin >> x[i]; }

    vector<ll> dp(K + 5, 0);
    dp[0] = 1;
    for (int i = 0; i < K + 5; i++) {
        for (int j = 0; j < N; j++) {
            if (i + x[j] < K + 5) {
                dp[i + x[j]] += dp[i];
                dp[i + x[j]] %= MOD;
            }
        }
    }

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