結果

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr int mod = 1e9+7;

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

  for (int i = 0; i < n; i++) {
    for (int j = n - 1; j >= 0; j--) {
      for (int k = 10000; k >= 0; k--) {
        if (k + a[i] <= 10000) (dp[j + 1][k + a[i]] += dp[j][k]) %= mod;
      }
    }
  }

  int res = 0;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= 10000; j++) {
      if (j >= k * i) (res += dp[i][j]) %= mod;
    }
  }

  cout << (res - 1 + mod) % mod << endl;
  return 0; 
}
0