結果

問題 No.1238 選抜クラス
ユーザー tonyu0
提出日時 2020-09-26 11:13:56
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 368 ms / 2,000 ms
コード長 870 bytes
コンパイル時間 1,198 ms
コンパイル使用メモリ 118,864 KB
最終ジャッジ日時 2025-01-14 22:05:22
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

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