結果

問題 No.1238 選抜クラス
ユーザー YamaKasaYamaKasa
提出日時 2020-09-26 19:31:41
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 26 ms / 2,000 ms
コード長 775 bytes
コンパイル時間 1,409 ms
コンパイル使用メモリ 164,812 KB
実行使用メモリ 19,308 KB
最終ジャッジ日時 2023-09-12 01:02:42
合計ジャッジ時間 3,267 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 3 ms
4,376 KB
testcase_02 AC 4 ms
4,808 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 4 ms
4,416 KB
testcase_08 AC 4 ms
4,956 KB
testcase_09 AC 5 ms
5,536 KB
testcase_10 AC 4 ms
4,448 KB
testcase_11 AC 5 ms
5,384 KB
testcase_12 AC 4 ms
4,908 KB
testcase_13 AC 4 ms
4,928 KB
testcase_14 AC 4 ms
4,748 KB
testcase_15 AC 5 ms
5,588 KB
testcase_16 AC 6 ms
5,400 KB
testcase_17 AC 26 ms
19,032 KB
testcase_18 AC 25 ms
18,524 KB
testcase_19 AC 24 ms
18,984 KB
testcase_20 AC 24 ms
18,312 KB
testcase_21 AC 23 ms
17,924 KB
testcase_22 AC 26 ms
19,168 KB
testcase_23 AC 25 ms
18,956 KB
testcase_24 AC 25 ms
19,308 KB
testcase_25 AC 26 ms
19,096 KB
testcase_26 AC 25 ms
18,988 KB
testcase_27 AC 25 ms
19,044 KB
testcase_28 AC 25 ms
18,960 KB
testcase_29 AC 25 ms
18,776 KB
testcase_30 AC 9 ms
8,032 KB
testcase_31 AC 14 ms
12,004 KB
testcase_32 AC 20 ms
15,396 KB
testcase_33 AC 3 ms
4,380 KB
testcase_34 AC 22 ms
16,644 KB
testcase_35 AC 11 ms
9,292 KB
testcase_36 AC 7 ms
6,176 KB
testcase_37 AC 9 ms
8,356 KB
testcase_38 AC 24 ms
18,396 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const ll mod = pow(10, 9) + 7;
const int l = 2 * 100 * 100 + 1;
const int m = 100 * 100;
ll dp[101][l + 1]{};

int main() {
    int N, K;
    cin >> N >> K;
    ll A[N];
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        A[i] -= K;
    }
    dp[0][m] = 1;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < l; j++) {
            dp[i + 1][j] += dp[i][j];
            dp[i + 1][j] %= mod;
            if (j + A[i] < 0 || j + A[i] >= l) continue;
            dp[i + 1][j + A[i]] += dp[i][j];
            dp[i + 1][j + A[i]] %= mod;
        }
    }
    ll s = 0;
    for (int i = m; i < l; i++) {
        s += dp[N][i];
        s %= mod;
    }
    cout << s - 1<< "\n";
    return 0;
}
0