結果

問題 No.1238 選抜クラス
ユーザー DaYuanChi
提出日時 2021-02-05 21:19:14
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 11 ms / 2,000 ms
コード長 638 bytes
コンパイル時間 1,398 ms
コンパイル使用メモリ 169,076 KB
実行使用メモリ 20,244 KB
最終ジャッジ日時 2024-07-02 11:28:51
合計ジャッジ時間 2,786 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

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

ll const MOD = 1e9+7;
ll dp[105][21000];

int main(){
  int n, k; cin >> n >> k;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    int A; cin >> A;
    A -= k;
    a[i] = A;
  }
  dp[0][10000] = 1;
  for(int i = 0; i < n; i++){
    for(int j = -10000; j <= 10000; j++){
      dp[i+1][j+10000] = (dp[i][j+10000])%MOD;
      dp[i+1][j+10000] = (dp[i+1][j+10000]+dp[i][j-a[i]+10000])%MOD;
    }
  }
  ll ans = 0;
  for(int i = 0; i <= 10000; i++){
    ans += (dp[n][i+10000])%MOD;
  }
  ans--;
  ans = (ans+MOD)%MOD;
  cout << ans << endl;
  return 0;
}
  
        
  
0