結果

問題 No.1238 選抜クラス
ユーザー sahiyasahiya
提出日時 2020-12-16 16:43:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 10 ms / 2,000 ms
コード長 1,686 bytes
コンパイル時間 1,638 ms
コンパイル使用メモリ 115,228 KB
実行使用メモリ 19,236 KB
最終ジャッジ日時 2023-10-20 09:41:39
合計ジャッジ時間 2,824 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 3 ms
5,968 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 3 ms
5,964 KB
testcase_08 AC 3 ms
5,968 KB
testcase_09 AC 3 ms
5,980 KB
testcase_10 AC 3 ms
5,968 KB
testcase_11 AC 3 ms
5,980 KB
testcase_12 AC 3 ms
5,968 KB
testcase_13 AC 3 ms
5,968 KB
testcase_14 AC 2 ms
5,968 KB
testcase_15 AC 3 ms
5,980 KB
testcase_16 AC 3 ms
5,980 KB
testcase_17 AC 10 ms
19,232 KB
testcase_18 AC 9 ms
18,764 KB
testcase_19 AC 10 ms
18,924 KB
testcase_20 AC 9 ms
18,460 KB
testcase_21 AC 8 ms
18,448 KB
testcase_22 AC 10 ms
19,232 KB
testcase_23 AC 10 ms
19,232 KB
testcase_24 AC 10 ms
19,236 KB
testcase_25 AC 10 ms
19,236 KB
testcase_26 AC 10 ms
19,232 KB
testcase_27 AC 10 ms
19,232 KB
testcase_28 AC 10 ms
19,232 KB
testcase_29 AC 9 ms
18,924 KB
testcase_30 AC 4 ms
10,112 KB
testcase_31 AC 5 ms
12,220 KB
testcase_32 AC 8 ms
16,364 KB
testcase_33 AC 2 ms
5,964 KB
testcase_34 AC 8 ms
18,436 KB
testcase_35 AC 4 ms
10,136 KB
testcase_36 AC 3 ms
8,040 KB
testcase_37 AC 4 ms
10,124 KB
testcase_38 AC 9 ms
18,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <forward_list>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef bitset<16> BS;

const ll MOD = 1E+09 + 7;
const ll INF = 1E18;
const int MAX_N = 100;

ll N, K;

ll A[MAX_N + 1], dp[MAX_N + 1][2 * MAX_N * MAX_N + 1];

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

    cin >> N >> K;

    for (int i = 1; i <= N; i++) {
        cin >> A[i];
        A[i] -= K;
    }

    dp[0][10000] = 1;
    for (int i = 1; i <= N; i++) {
        for (int j = 0; j <= 100 * N + 10000; j++) {
            dp[i][j] = dp[i - 1][j];
            if (j >= A[i] && j - A[i] <= 100 * N + 10000) {
                dp[i][j] += dp[i - 1][j - A[i]];
                dp[i][j] %= MOD;
            }
            /*
            if (dp[i][j] != 0) {
                cout << "i = " << i << ", j = " << j << ", dp = " << dp[i][j] << "\n";
            }
            */
        }
    }

    ll ans = 0;
    for (int j = 10000; j <= 100 * N + 10000; j++) {
        ans += dp[N][j];
        ans %= MOD;
    }

    /*
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cout << "i = " << i << ", j = " << j << ", dp = " << dp[i][j] << "\n";
        }
    }
    */

    cout << (ans - 1 + MOD) % MOD << "\n";

    return 0;
}
0