結果

問題 No.2625 Bouns Ai
ユーザー kokoseikokosei
提出日時 2024-02-09 22:04:33
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 16 ms / 2,000 ms
コード長 1,345 bytes
コンパイル時間 2,958 ms
コンパイル使用メモリ 249,324 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-02-09 22:04:37
合計ジャッジ時間 3,461 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 16 ms
6,676 KB
testcase_02 AC 15 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 13 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 1 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 1 ms
6,676 KB
testcase_09 AC 1 ms
6,676 KB
testcase_10 AC 14 ms
6,676 KB
testcase_11 AC 1 ms
6,676 KB
testcase_12 AC 14 ms
6,676 KB
testcase_13 AC 1 ms
6,676 KB
testcase_14 AC 13 ms
6,676 KB
testcase_15 AC 12 ms
6,676 KB
testcase_16 AC 12 ms
6,676 KB
testcase_17 AC 12 ms
6,676 KB
testcase_18 AC 13 ms
6,676 KB
testcase_19 AC 12 ms
6,676 KB
testcase_20 AC 12 ms
6,676 KB
testcase_21 AC 11 ms
6,676 KB
testcase_22 AC 5 ms
6,676 KB
testcase_23 AC 5 ms
6,676 KB
testcase_24 AC 6 ms
6,676 KB
testcase_25 AC 5 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#include <bits/stdc++.h>
#include <atcoder/modint>
using namespace std;
using mint = atcoder::modint998244353;

class FPC{
    private:
    int size;
    vector<mint> ff, fi;
    public:
    FPC(int _n = 0) : size(_n), ff(_n + 1), fi(_n + 1){
        ff[0] = fi[0] = 1;
        for(int i = 1;i <= size;i++){
            ff[i] = ff[i - 1] * i;
            fi[i] = ff[i].inv();
        }
    }
    mint fact(int n) const{
        assert(0 <= n && n <= size);
        return ff[n];
    }
    mint faci(int n) const{
        assert(0 <= n && n <= size);
        return fi[n];
    }
    mint parm(int n, int r) const{
        assert(0 <= n && n <= size);
        assert(0 <= r && r <= size);
        return ff[n] * fi[r];
    }
    mint comb(int n, int r) const{
        assert(0 <= n && n <= size);
        assert(0 <= r && r <= size);
        assert(n >= r);
        return ff[n] * fi[r] * fi[n - r];
    }
};
int N;
int A[210];
int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    cin >> N;
    for(int i = 0;i < N;i++)cin >> A[i];
    int n = (int)1e5 + 1;
    for(int i = 0;i < N;i++){
        n -= max(0, A[i] - A[i + 1]);
    }
    FPC fpc(n + N);
    mint ans = (n < 1 ? 0 : fpc.comb(n + N - 1, N));
    cout << ans.val() << endl;
    return 0;
}
0