結果

問題 No.1238 選抜クラス
ユーザー wakapaijazzwakapaijazz
提出日時 2020-10-01 09:47:02
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 19 ms / 2,000 ms
コード長 1,335 bytes
コンパイル時間 2,048 ms
コンパイル使用メモリ 204,152 KB
実行使用メモリ 20,068 KB
最終ジャッジ日時 2023-09-21 06:45:53
合計ジャッジ時間 4,350 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 3 ms
4,392 KB
testcase_02 AC 4 ms
5,352 KB
testcase_03 AC 3 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 3 ms
4,376 KB
testcase_07 AC 4 ms
4,892 KB
testcase_08 AC 4 ms
5,364 KB
testcase_09 AC 5 ms
6,304 KB
testcase_10 AC 4 ms
5,116 KB
testcase_11 AC 5 ms
6,196 KB
testcase_12 AC 4 ms
5,664 KB
testcase_13 AC 4 ms
5,644 KB
testcase_14 AC 3 ms
5,364 KB
testcase_15 AC 4 ms
6,232 KB
testcase_16 AC 5 ms
6,264 KB
testcase_17 AC 19 ms
19,932 KB
testcase_18 AC 19 ms
19,508 KB
testcase_19 AC 19 ms
19,660 KB
testcase_20 AC 18 ms
19,260 KB
testcase_21 AC 17 ms
18,768 KB
testcase_22 AC 19 ms
20,024 KB
testcase_23 AC 19 ms
19,932 KB
testcase_24 AC 19 ms
20,004 KB
testcase_25 AC 19 ms
20,052 KB
testcase_26 AC 19 ms
20,060 KB
testcase_27 AC 19 ms
20,068 KB
testcase_28 AC 19 ms
20,048 KB
testcase_29 AC 19 ms
19,712 KB
testcase_30 AC 7 ms
8,844 KB
testcase_31 AC 12 ms
12,752 KB
testcase_32 AC 16 ms
16,320 KB
testcase_33 AC 3 ms
4,876 KB
testcase_34 AC 16 ms
17,580 KB
testcase_35 AC 9 ms
10,164 KB
testcase_36 AC 6 ms
6,952 KB
testcase_37 AC 8 ms
9,052 KB
testcase_38 AC 18 ms
19,252 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main(){
    const int MOD = 1e9 + 7;
    int n, k; cin >> n >> k;
    vi a(n); rep(i, n) {
        cin >> a[i];
        a[i] -= k;
    }
    vector<vll> dp(n+5, vll(20010, 0));
    dp[0][10000] = 1;
    
    rep(i, n){
        rep3(S, -10000, 10000){
            // cout << i << " " << S << endl;
            if(S+10000-a[i] >= 0) {
                dp[i+1][S+10000] += (dp[i][S+10000] + dp[i][S+10000-a[i]]);
                dp[i+1][S+10000] %= MOD;
            }else{
                dp[i+1][S+10000] = dp[i][S+10000];
            }
        }
    }
    
    ll ans = 0;
    rep3(i, 10000, 20001) {
        ans += dp[n][i];
        ans %= MOD;
    }
    cout << (ans + MOD - 1) % MOD << endl;
    return;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}
0