結果

問題 No.3046 yukicoderの過去問
ユーザー Gosu_HirooGosu_Hiroo
提出日時 2020-08-03 20:56:24
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,945 ms / 2,000 ms
コード長 729 bytes
コンパイル時間 3,033 ms
コンパイル使用メモリ 212,576 KB
実行使用メモリ 4,692 KB
最終ジャッジ日時 2023-10-11 17:17:43
合計ジャッジ時間 13,500 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,352 KB
testcase_03 AC 1,933 ms
4,352 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 1,935 ms
4,348 KB
testcase_06 AC 1,945 ms
4,692 KB
testcase_07 AC 1,937 ms
4,460 KB
testcase_08 AC 1,942 ms
4,576 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include "bits/stdc++.h"

using namespace std;

#define repeat(cnt,l) for(auto cnt=decltype(l)();(cnt)<(l);++(cnt))


//

const int MD = 1000000007;
int N, K;
int X[100010];


void input() {
    cin >> K >> N;
    repeat(i, N) scanf("%d", X + i);
}


//


int dp[100010];
int f[100010];

int solve() {
    fill(dp, dp + K + 1, 0);
    fill(f, f + K + 1, 0);
    repeat(i, N) f[X[i]] = 1;
    dp[0] = 1;
    repeat(k, K) {
        const int v = dp[k];
        repeat(i, K - k + 1) {
            dp[i + k] += v * f[i];
            dp[i + k] -= MD*(dp[i + k] >= MD);
        }
    }
    return dp[K];
}


int main() {

    input();
    cout << solve() << endl;

    return 0;
}
0