結果

問題 No.1693 Invasion
ユーザー chocoruskchocorusk
提出日時 2021-10-02 17:51:40
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 13 ms / 2,000 ms
コード長 1,388 bytes
コンパイル時間 3,463 ms
コンパイル使用メモリ 187,832 KB
実行使用メモリ 19,568 KB
最終ジャッジ日時 2023-09-27 18:20:17
合計ジャッジ時間 4,695 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
19,036 KB
testcase_01 AC 7 ms
19,048 KB
testcase_02 AC 7 ms
19,048 KB
testcase_03 AC 7 ms
19,036 KB
testcase_04 AC 7 ms
19,040 KB
testcase_05 AC 7 ms
19,180 KB
testcase_06 AC 7 ms
19,184 KB
testcase_07 AC 7 ms
18,976 KB
testcase_08 AC 7 ms
19,044 KB
testcase_09 AC 11 ms
19,264 KB
testcase_10 AC 10 ms
19,404 KB
testcase_11 AC 8 ms
19,256 KB
testcase_12 AC 10 ms
19,504 KB
testcase_13 AC 9 ms
19,164 KB
testcase_14 AC 9 ms
19,200 KB
testcase_15 AC 8 ms
19,056 KB
testcase_16 AC 9 ms
19,156 KB
testcase_17 AC 8 ms
19,168 KB
testcase_18 AC 12 ms
19,568 KB
testcase_19 AC 8 ms
19,488 KB
testcase_20 AC 7 ms
19,116 KB
testcase_21 AC 13 ms
19,360 KB
testcase_22 AC 12 ms
19,408 KB
testcase_23 AC 13 ms
19,480 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;
using mint=modint998244353;
mint f[2000010], invf[2000010];
void fac(int n){
    f[0]=1;
    for(ll i=1; i<=n; i++) f[i]=f[i-1]*i;
    invf[n]=f[n].inv();
    for(ll i=n-1; i>=0; i--) invf[i]=invf[i+1]*(i+1);
}
mint comb(int x, int y){
    if(!(0<=y && y<=x)) return 0;
    return f[x]*invf[y]*invf[x-y];
}
int n, m; 
int a[101];
int dp[100010];
int main()
{
    cin>>n>>m;
    for(int i=0; i<n; i++){
        cin>>a[i];
    }
    fac(m);
    const int INF=1e9;
    for(int j=0; j<=m; j++) dp[j]=INF;
    dp[0]=0;
    for(int i=0; i<n; i++){
        for(int j=0; j<=m-a[i]; j++){
            dp[j+a[i]]=min(dp[j+a[i]], dp[j]+1);
        }
    }
    mint ans=0;
    for(int i=0; i<=m; i++){
        if(dp[i]<INF)ans+=comb(m-dp[i], i-dp[i]);
    }
    cout<<ans.val()<<endl;
    return 0;
}
0