結果

問題 No.1238 選抜クラス
ユーザー 👑 platinumplatinum
提出日時 2020-09-07 23:04:26
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 128 ms / 2,000 ms
コード長 904 bytes
コンパイル時間 1,452 ms
コンパイル使用メモリ 168,852 KB
実行使用メモリ 19,200 KB
最終ジャッジ日時 2024-05-07 00:19:10
合計ジャッジ時間 4,295 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 3 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 3 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 125 ms
19,072 KB
testcase_18 AC 115 ms
18,688 KB
testcase_19 AC 115 ms
18,688 KB
testcase_20 AC 108 ms
18,176 KB
testcase_21 AC 96 ms
17,280 KB
testcase_22 AC 124 ms
19,200 KB
testcase_23 AC 119 ms
19,072 KB
testcase_24 AC 124 ms
19,072 KB
testcase_25 AC 122 ms
19,072 KB
testcase_26 AC 125 ms
19,072 KB
testcase_27 AC 128 ms
19,072 KB
testcase_28 AC 124 ms
19,072 KB
testcase_29 AC 117 ms
18,688 KB
testcase_30 AC 6 ms
5,376 KB
testcase_31 AC 25 ms
8,576 KB
testcase_32 AC 59 ms
13,312 KB
testcase_33 AC 2 ms
5,376 KB
testcase_34 AC 79 ms
15,360 KB
testcase_35 AC 10 ms
6,016 KB
testcase_36 AC 3 ms
5,376 KB
testcase_37 AC 7 ms
5,376 KB
testcase_38 AC 109 ms
18,304 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