結果

問題 No.1693 Invasion
ユーザー XDXD
提出日時 2021-10-02 17:25:01
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 8 ms / 2,000 ms
コード長 1,751 bytes
コンパイル時間 1,323 ms
コンパイル使用メモリ 165,172 KB
実行使用メモリ 4,856 KB
最終ジャッジ日時 2023-09-27 17:53:45
合計ジャッジ時間 2,480 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 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 1 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 6 ms
4,632 KB
testcase_10 AC 5 ms
4,648 KB
testcase_11 AC 3 ms
4,424 KB
testcase_12 AC 5 ms
4,660 KB
testcase_13 AC 3 ms
4,376 KB
testcase_14 AC 4 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 4 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 7 ms
4,720 KB
testcase_19 AC 4 ms
4,856 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 8 ms
4,696 KB
testcase_22 AC 6 ms
4,784 KB
testcase_23 AC 7 ms
4,684 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define forn(i,s,t) for(register int i=(s); i<=(t); ++i)
#define form(i,s,t) for(register int i=(s); i>=(t); --i)
#define rep(i,s,t) for(register int i=(s); i<(t); ++i)
using namespace std;
const int N = 1e2 + 3, M = 1e5 + 3, Mod = 998244353;
struct Mint {
	int res;
	Mint() {}
	Mint(int _r) : res(_r) {}
	inline friend Mint operator + (const Mint& A, const Mint& B) {
		return Mint((A.res + B.res) >= Mod ? A.res + B.res - Mod : A.res + B.res);
	}
	inline friend Mint operator - (const Mint& A, const Mint& B) {return A + Mint(Mod - B.res);}
	inline friend Mint operator * (const Mint& A, const Mint& B) {return Mint(1ll * A.res * B.res % Mod);}
	inline friend Mint& operator += (Mint& A, const Mint& B) {return A = A + B;}
	inline friend Mint& operator -= (Mint& A, const Mint& B) {return A = A - B;}
	inline friend Mint& operator *= (Mint& A, const Mint& B) {return A = A * B;}
	inline friend Mint q_pow(Mint p, int k = Mod - 2) {
		Mint res = Mint(1);
		for(; k; k >>= 1, p *= p) (k & 1) && (res *= p, 0);
		return res;
	}
	inline friend Mint operator ~ (Mint A) {return q_pow(A);}
} ;
Mint fac[M], ifac[M];
inline void table(int lim) {
	fac[0] = Mint(1);
	forn(i,1,lim) fac[i] = fac[i - 1] * Mint(i);
	ifac[lim] = ~fac[lim];
	form(i,lim - 1,0) ifac[i] = ifac[i + 1] * Mint(i + 1);
}
inline Mint C(int n, int r) {
	if(n < 0 || r < 0 || n < r) return Mint(0);
	return fac[n] * ifac[r] * ifac[n - r];
}
int n, m, a[N], f[M];
int main() {
	scanf("%d%d", &n, &m), table(m);
	forn(i,1,n) scanf("%d", a + i);
	memset(f, 0x3f, sizeof f);
	int inf = f[0]; f[0] = 0;
	forn(i,1,n) forn(j,a[i],m) f[j] = min(f[j], f[j - a[i]] + 1);
	Mint res = Mint(0);
	forn(i,0,m) res += C(m - f[i], i - f[i]);
	printf("%d\n", res.res);
	return 0;
}
0