結果

問題 No.1238 選抜クラス
ユーザー simkarensimkaren
提出日時 2020-11-30 09:48:02
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 21 ms / 2,000 ms
コード長 976 bytes
コンパイル時間 2,658 ms
コンパイル使用メモリ 188,176 KB
実行使用メモリ 19,532 KB
最終ジャッジ日時 2023-10-11 02:47:19
合計ジャッジ時間 6,137 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 3 ms
4,376 KB
testcase_02 AC 3 ms
4,948 KB
testcase_03 AC 2 ms
4,372 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,372 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 3 ms
4,376 KB
testcase_08 AC 3 ms
4,952 KB
testcase_09 AC 4 ms
5,628 KB
testcase_10 AC 3 ms
4,424 KB
testcase_11 AC 4 ms
5,424 KB
testcase_12 AC 4 ms
4,996 KB
testcase_13 AC 3 ms
4,864 KB
testcase_14 AC 3 ms
5,020 KB
testcase_15 AC 4 ms
5,688 KB
testcase_16 AC 4 ms
5,364 KB
testcase_17 AC 19 ms
19,408 KB
testcase_18 AC 18 ms
19,184 KB
testcase_19 AC 18 ms
19,208 KB
testcase_20 AC 18 ms
18,748 KB
testcase_21 AC 18 ms
18,092 KB
testcase_22 AC 21 ms
19,348 KB
testcase_23 AC 19 ms
19,528 KB
testcase_24 AC 19 ms
19,364 KB
testcase_25 AC 20 ms
19,524 KB
testcase_26 AC 19 ms
19,412 KB
testcase_27 AC 19 ms
19,420 KB
testcase_28 AC 19 ms
19,532 KB
testcase_29 AC 19 ms
19,136 KB
testcase_30 AC 7 ms
8,256 KB
testcase_31 AC 11 ms
12,336 KB
testcase_32 AC 16 ms
15,848 KB
testcase_33 AC 3 ms
4,376 KB
testcase_34 AC 16 ms
16,980 KB
testcase_35 AC 9 ms
9,532 KB
testcase_36 AC 5 ms
6,528 KB
testcase_37 AC 8 ms
8,576 KB
testcase_38 AC 18 ms
18,556 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("Ofast", "unroll-loops")
#pragma GCC target("avx2")

#include <bits/stdc++.h>

using namespace std;

#define ll long long

constexpr ll mod = 1000000007LL;

int N, K;
vector<int> A;

void input(void){
    cin >> N >> K;
    A.resize(N);
    for (int& ai : A)
        cin >> ai;
}

constexpr int offset = 10000;

ll solve(void){
    for (int& ai : A)
        ai -= K;
    vector<vector<ll>> dp(
        N + 1, vector<ll>(2 * offset + 1, 0)
    );
    dp[0][offset] = 1;
    for (int i = 1; i <= N; ++i){
        int a = A[i - 1];
        for (int s = 0; s <= 2 * offset; ++s){
            dp[i][s] = dp[i - 1][s];
            if (0 <= s - a && s - a <= 2 * offset)
                dp[i][s] = (dp[i][s] + dp[i - 1][s - a]) % mod;
        }
    }
    ll ret = 0;
    for (int s = offset; s <= 2 * offset; ++s)
        ret = (ret + dp[N][s]) % mod;
    return (ret + mod - 1) % mod;
}

int main(void){
    input();
    cout << solve() << endl;
    return 0;
}
0