結果

問題 No.1693 Invasion
ユーザー 夜
提出日時 2021-10-01 23:07:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 27 ms / 2,000 ms
コード長 1,224 bytes
コンパイル時間 907 ms
コンパイル使用メモリ 93,800 KB
実行使用メモリ 8,540 KB
最終ジャッジ日時 2023-09-26 22:02:49
合計ジャッジ時間 2,372 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,224 KB
testcase_01 AC 16 ms
8,000 KB
testcase_02 AC 16 ms
8,096 KB
testcase_03 AC 16 ms
8,056 KB
testcase_04 AC 16 ms
8,016 KB
testcase_05 AC 15 ms
8,128 KB
testcase_06 AC 16 ms
8,024 KB
testcase_07 AC 14 ms
8,008 KB
testcase_08 AC 14 ms
8,280 KB
testcase_09 AC 22 ms
8,292 KB
testcase_10 AC 19 ms
8,468 KB
testcase_11 AC 17 ms
8,396 KB
testcase_12 AC 21 ms
8,456 KB
testcase_13 AC 18 ms
8,212 KB
testcase_14 AC 19 ms
8,172 KB
testcase_15 AC 17 ms
8,092 KB
testcase_16 AC 19 ms
8,208 KB
testcase_17 AC 15 ms
8,024 KB
testcase_18 AC 24 ms
8,384 KB
testcase_19 AC 16 ms
8,408 KB
testcase_20 AC 15 ms
8,016 KB
testcase_21 AC 25 ms
8,372 KB
testcase_22 AC 25 ms
8,532 KB
testcase_23 AC 27 ms
8,540 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
#include <fstream>
using namespace std;
long long fac[200020], finv[200020], inv[200020];
long long mod = 998244353;
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < 200020; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
long long COM(long long n, long long k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
int a[110];
int dp[100010];
int main() {
	COMinit();
	int n, m;
	cin >> n >> m;
	dp[0] = 0;
	for (int i = 1; i <= m; i++) {
		dp[i] = 1000000007;
	}
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		for (int j = 0; j <= m - a; j++) {
			dp[j + a] = min(dp[j] + 1, dp[j + a]);
		}
	}
	long long ans = 0;
	for (int i = 0; i <= m; i++) {
		if (dp[i] != 1000000007) {
			ans += COM(m - dp[i], i - dp[i]);
			ans %= mod;
		}
	}
	cout << ans << endl;
}
0