結果

問題 No.1238 選抜クラス
ユーザー tonyu0tonyu0
提出日時 2020-09-26 11:13:56
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 363 ms / 2,000 ms
コード長 870 bytes
コンパイル時間 1,195 ms
コンパイル使用メモリ 121,732 KB
実行使用メモリ 5,128 KB
最終ジャッジ日時 2023-09-11 07:05:23
合計ジャッジ時間 9,414 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
4,872 KB
testcase_01 AC 14 ms
4,824 KB
testcase_02 AC 34 ms
4,952 KB
testcase_03 AC 8 ms
4,712 KB
testcase_04 AC 7 ms
4,896 KB
testcase_05 AC 8 ms
4,904 KB
testcase_06 AC 7 ms
4,868 KB
testcase_07 AC 24 ms
4,876 KB
testcase_08 AC 34 ms
4,940 KB
testcase_09 AC 50 ms
4,880 KB
testcase_10 AC 27 ms
4,740 KB
testcase_11 AC 47 ms
4,828 KB
testcase_12 AC 37 ms
4,968 KB
testcase_13 AC 37 ms
4,792 KB
testcase_14 AC 34 ms
4,944 KB
testcase_15 AC 51 ms
4,832 KB
testcase_16 AC 48 ms
4,900 KB
testcase_17 AC 359 ms
4,832 KB
testcase_18 AC 347 ms
4,740 KB
testcase_19 AC 351 ms
4,952 KB
testcase_20 AC 344 ms
4,904 KB
testcase_21 AC 326 ms
4,760 KB
testcase_22 AC 356 ms
5,128 KB
testcase_23 AC 355 ms
4,900 KB
testcase_24 AC 357 ms
4,980 KB
testcase_25 AC 361 ms
5,120 KB
testcase_26 AC 358 ms
4,860 KB
testcase_27 AC 363 ms
4,804 KB
testcase_28 AC 358 ms
4,876 KB
testcase_29 AC 352 ms
4,904 KB
testcase_30 AC 107 ms
4,816 KB
testcase_31 AC 197 ms
4,880 KB
testcase_32 AC 275 ms
4,832 KB
testcase_33 AC 24 ms
4,736 KB
testcase_34 AC 303 ms
5,088 KB
testcase_35 AC 135 ms
4,872 KB
testcase_36 AC 65 ms
4,768 KB
testcase_37 AC 115 ms
4,800 KB
testcase_38 AC 345 ms
4,824 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <complex>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <unordered_map>
#include <vector>
#define rep(i, j, n) for (int i = (j); i < (int)(n); ++i)
#define rrep(i, j, n) for (int i = (n)-1; i >= (int(j); --i)
using namespace std;
using ll = long long;
constexpr int INF = 1 << 30;
constexpr ll MOD = 1000000007;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, 0, n) {
    cin >> a[i];
    a[i] -= k;
  }
  unordered_map<int, int> dp;
  dp[0] = 1;

  rep(i, 0, n) {
    unordered_map<int, int> ndp;
    for (int j = 10000; j >= -10000; --j) {
      ndp[j + a[i]] += dp[j];
      ndp[j] += dp[j];
      ndp[j + a[i]] %= MOD;
      ndp[j] %= MOD;
    }
    dp = ndp;
  }
  ll ans = 0;
  rep(i, 0, 10001) {
    ans += dp[i];
    ans %= MOD;
  }
  cout << ans - 1 << endl;
  return 0;
}
0