結果

問題 No.1238 選抜クラス
ユーザー leaf_1415leaf_1415
提出日時 2020-09-25 21:39:58
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 39 ms / 2,000 ms
コード長 1,366 bytes
コンパイル時間 2,399 ms
コンパイル使用メモリ 74,060 KB
実行使用メモリ 26,900 KB
最終ジャッジ日時 2023-09-10 15:04:00
合計ジャッジ時間 3,019 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,376 KB
testcase_01 AC 3 ms
4,380 KB
testcase_02 AC 5 ms
5,528 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 4 ms
4,768 KB
testcase_08 AC 6 ms
5,460 KB
testcase_09 AC 8 ms
6,632 KB
testcase_10 AC 5 ms
4,992 KB
testcase_11 AC 7 ms
6,632 KB
testcase_12 AC 6 ms
5,688 KB
testcase_13 AC 6 ms
5,696 KB
testcase_14 AC 6 ms
5,504 KB
testcase_15 AC 8 ms
6,740 KB
testcase_16 AC 7 ms
6,500 KB
testcase_17 AC 38 ms
26,804 KB
testcase_18 AC 38 ms
26,104 KB
testcase_19 AC 38 ms
26,328 KB
testcase_20 AC 37 ms
25,656 KB
testcase_21 AC 36 ms
24,984 KB
testcase_22 AC 38 ms
26,796 KB
testcase_23 AC 38 ms
26,792 KB
testcase_24 AC 39 ms
26,792 KB
testcase_25 AC 38 ms
26,900 KB
testcase_26 AC 38 ms
26,860 KB
testcase_27 AC 38 ms
26,892 KB
testcase_28 AC 38 ms
26,776 KB
testcase_29 AC 38 ms
26,296 KB
testcase_30 AC 13 ms
10,420 KB
testcase_31 AC 22 ms
16,276 KB
testcase_32 AC 29 ms
21,468 KB
testcase_33 AC 4 ms
4,924 KB
testcase_34 AC 33 ms
23,324 KB
testcase_35 AC 16 ms
12,232 KB
testcase_36 AC 9 ms
7,636 KB
testcase_37 AC 14 ms
10,888 KB
testcase_38 AC 37 ms
25,628 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define mod 1000000007

using namespace std;
typedef pair<llint, llint> P;

llint n, k;
llint a[105];
llint dp[105][30005];
llint zero = 15002;

llint modpow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod) * (modpow(a, n-1)%mod)) % mod;
	}
	else{
		return modpow((a*a)%mod, n/2) % mod;
	}
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> k;
	for(int i = 1; i <= n; i++) cin >> a[i], a[i] -= k;
	
	dp[0][zero] = 1;
	for(int i = 0; i < n; i++){
		for(int j = -15000; j <= 15000; j++){
			(dp[i+1][zero+j] += dp[i][zero+j]) %= mod;
			if(abs(j+a[i+1]) <= 15000){
				(dp[i+1][zero+j+a[i+1]] += dp[i][zero+j]) %= mod;
			}
		}
	}
	llint ans = 0;
	for(int i = 0; i <= 15000; i++) ans += dp[n][zero+i], ans %= mod;
	ans += mod - 1, ans %= mod;
	cout << ans << endl;
	
	return 0;
}
0