結果

問題 No.1238 選抜クラス
ユーザー 👑 platinumplatinum
提出日時 2020-09-07 23:04:26
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 86 ms / 2,000 ms
コード長 904 bytes
コンパイル時間 3,832 ms
コンパイル使用メモリ 167,348 KB
実行使用メモリ 19,616 KB
最終ジャッジ日時 2023-08-19 17:18:43
合計ジャッジ時間 4,175 ms
ジャッジサーバーID
(参考情報)
judge10 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,360 KB
testcase_01 AC 2 ms
5,472 KB
testcase_02 AC 1 ms
5,500 KB
testcase_03 AC 2 ms
5,476 KB
testcase_04 AC 1 ms
5,596 KB
testcase_05 AC 1 ms
5,528 KB
testcase_06 AC 2 ms
5,528 KB
testcase_07 AC 2 ms
5,412 KB
testcase_08 AC 2 ms
5,488 KB
testcase_09 AC 2 ms
5,624 KB
testcase_10 AC 2 ms
5,416 KB
testcase_11 AC 2 ms
5,640 KB
testcase_12 AC 2 ms
5,588 KB
testcase_13 AC 2 ms
5,660 KB
testcase_14 AC 2 ms
5,500 KB
testcase_15 AC 2 ms
5,920 KB
testcase_16 AC 1 ms
5,532 KB
testcase_17 AC 85 ms
19,332 KB
testcase_18 AC 76 ms
19,176 KB
testcase_19 AC 77 ms
19,272 KB
testcase_20 AC 74 ms
19,104 KB
testcase_21 AC 65 ms
18,544 KB
testcase_22 AC 84 ms
19,568 KB
testcase_23 AC 84 ms
19,424 KB
testcase_24 AC 86 ms
19,376 KB
testcase_25 AC 81 ms
19,332 KB
testcase_26 AC 85 ms
19,392 KB
testcase_27 AC 85 ms
19,616 KB
testcase_28 AC 85 ms
19,384 KB
testcase_29 AC 80 ms
19,232 KB
testcase_30 AC 5 ms
8,268 KB
testcase_31 AC 18 ms
12,124 KB
testcase_32 AC 40 ms
14,620 KB
testcase_33 AC 2 ms
5,588 KB
testcase_34 AC 55 ms
17,540 KB
testcase_35 AC 8 ms
8,716 KB
testcase_36 AC 3 ms
5,696 KB
testcase_37 AC 5 ms
8,440 KB
testcase_38 AC 72 ms
19,100 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;
using LL = long long;
const LL mod = 1e9 + 7;
const int Max_N = 100;
const int Max_K = 100;
const int Max_A = 100;

LL dp[2][Max_N + 5][Max_N * Max_A + 5];

int main(){
	int N, K;
	cin >> N >> K;
	assert(1 <= N and N <= Max_N);
	assert(0 <= K and K <= Max_K);
	vector<int> A(N);
	rep(i,N){
		int a;
		cin >> a;
		assert(0 <= a and a <= Max_A);
		A[i] = a;
	}
	dp[0][0][0] = 1;
	for(int i = 1; i <= N; i++){
		for(int j = 0; j <= i; j++){
			for(int S = 0; S <= i * Max_A; S++){
				dp[i%2][j][S] = dp[(i+1)%2][j][S];
				if(S >= A[i-1] and j > 0){
					dp[i%2][j][S] += dp[(i+1)%2][j-1][S-A[i-1]];
				}
				dp[i%2][j][S] %= mod;
			}
		}
	}
	LL ans = 0;
	for(int j = 1; j <= N; j++){
		for(int S = j * K; S <= j * Max_A; S++){
			ans += dp[N%2][j][S];
			ans %= mod;
		}
	}
	cout << ans << endl;

	return 0;
}
0