結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 AC 2 ms
4,352 KB
testcase_03 AC 2 ms
4,356 KB
testcase_04 AC 2 ms
4,352 KB
testcase_05 AC 2 ms
4,352 KB
testcase_06 AC 2 ms
4,352 KB
testcase_07 AC 2 ms
4,352 KB
testcase_08 AC 3 ms
4,352 KB
testcase_09 AC 3 ms
4,352 KB
testcase_10 AC 2 ms
4,352 KB
testcase_11 AC 3 ms
4,352 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 3 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 3 ms
4,356 KB
testcase_16 AC 3 ms
4,372 KB
testcase_17 AC 6 ms
4,352 KB
testcase_18 AC 5 ms
4,352 KB
testcase_19 AC 6 ms
4,352 KB
testcase_20 AC 6 ms
4,356 KB
testcase_21 AC 5 ms
4,352 KB
testcase_22 AC 7 ms
4,348 KB
testcase_23 AC 6 ms
4,352 KB
testcase_24 AC 6 ms
4,352 KB
testcase_25 AC 7 ms
4,352 KB
testcase_26 AC 6 ms
4,368 KB
testcase_27 AC 6 ms
4,352 KB
testcase_28 AC 6 ms
4,348 KB
testcase_29 AC 6 ms
4,352 KB
testcase_30 AC 3 ms
4,348 KB
testcase_31 AC 4 ms
4,352 KB
testcase_32 AC 5 ms
4,352 KB
testcase_33 AC 2 ms
4,372 KB
testcase_34 AC 5 ms
4,348 KB
testcase_35 AC 3 ms
4,348 KB
testcase_36 AC 2 ms
4,352 KB
testcase_37 AC 4 ms
4,352 KB
testcase_38 AC 5 ms
4,352 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(
        2, 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 & 1][s] = dp[(i - 1) & 1][s];
            if (0 <= s - a && s - a <= 2 * offset)
                dp[i & 1][s] = (dp[i & 1][s] + dp[(i - 1) & 1][s - a]) % mod;
        }
    }
    ll ret = 0;
    for (int s = offset; s <= 2 * offset; ++s)
        ret = (ret + dp[N & 1][s]) % mod;
    return (ret + mod - 1) % mod;
}

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