結果

問題 No.1238 選抜クラス
ユーザー sahiyasahiya
提出日時 2020-12-16 16:32:29
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,655 bytes
コンパイル時間 1,666 ms
コンパイル使用メモリ 114,668 KB
実行使用メモリ 19,312 KB
最終ジャッジ日時 2023-10-20 09:41:16
合計ジャッジ時間 2,847 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 3 ms
6,044 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
6,040 KB
testcase_08 AC 3 ms
6,044 KB
testcase_09 AC 3 ms
6,056 KB
testcase_10 AC 3 ms
6,044 KB
testcase_11 AC 3 ms
6,056 KB
testcase_12 AC 3 ms
6,044 KB
testcase_13 AC 3 ms
6,044 KB
testcase_14 AC 3 ms
6,044 KB
testcase_15 AC 3 ms
6,056 KB
testcase_16 AC 3 ms
6,056 KB
testcase_17 AC 10 ms
19,308 KB
testcase_18 AC 10 ms
18,840 KB
testcase_19 AC 10 ms
19,000 KB
testcase_20 AC 9 ms
18,536 KB
testcase_21 AC 9 ms
18,524 KB
testcase_22 AC 10 ms
19,308 KB
testcase_23 WA -
testcase_24 AC 11 ms
19,312 KB
testcase_25 AC 11 ms
19,312 KB
testcase_26 AC 10 ms
19,308 KB
testcase_27 AC 10 ms
19,308 KB
testcase_28 AC 10 ms
19,308 KB
testcase_29 AC 10 ms
19,000 KB
testcase_30 AC 4 ms
10,188 KB
testcase_31 AC 6 ms
12,296 KB
testcase_32 AC 8 ms
16,440 KB
testcase_33 AC 3 ms
6,040 KB
testcase_34 AC 8 ms
18,512 KB
testcase_35 AC 4 ms
10,212 KB
testcase_36 AC 4 ms
8,116 KB
testcase_37 AC 4 ms
10,200 KB
testcase_38 AC 10 ms
18,536 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]) {
                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