結果

問題 No.1238 選抜クラス
ユーザー iqueue02iqueue02
提出日時 2020-09-25 23:17:08
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 229 ms / 2,000 ms
コード長 782 bytes
コンパイル時間 2,155 ms
コンパイル使用メモリ 202,204 KB
実行使用メモリ 7,184 KB
最終ジャッジ日時 2023-09-10 16:17:19
合計ジャッジ時間 7,100 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 4 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 3 ms
4,380 KB
testcase_08 AC 4 ms
4,376 KB
testcase_09 AC 7 ms
4,376 KB
testcase_10 AC 3 ms
4,384 KB
testcase_11 AC 6 ms
4,380 KB
testcase_12 AC 4 ms
4,380 KB
testcase_13 AC 4 ms
4,380 KB
testcase_14 AC 4 ms
4,380 KB
testcase_15 AC 7 ms
4,376 KB
testcase_16 AC 6 ms
4,380 KB
testcase_17 AC 227 ms
7,032 KB
testcase_18 AC 213 ms
7,012 KB
testcase_19 AC 217 ms
7,024 KB
testcase_20 AC 206 ms
6,708 KB
testcase_21 AC 192 ms
6,748 KB
testcase_22 AC 228 ms
6,980 KB
testcase_23 AC 226 ms
7,184 KB
testcase_24 AC 227 ms
6,944 KB
testcase_25 AC 226 ms
7,036 KB
testcase_26 AC 229 ms
6,968 KB
testcase_27 AC 227 ms
7,168 KB
testcase_28 AC 226 ms
6,940 KB
testcase_29 AC 218 ms
6,964 KB
testcase_30 AC 24 ms
4,432 KB
testcase_31 AC 72 ms
5,168 KB
testcase_32 AC 136 ms
6,188 KB
testcase_33 AC 3 ms
4,380 KB
testcase_34 AC 166 ms
6,620 KB
testcase_35 AC 36 ms
4,588 KB
testcase_36 AC 10 ms
4,380 KB
testcase_37 AC 26 ms
4,404 KB
testcase_38 AC 203 ms
6,708 KB
権限があれば一括ダウンロードができます

ソースコード

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