結果

問題 No.2625 Bouns Ai
ユーザー 寝癖寝癖
提出日時 2024-02-10 10:22:53
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 157 ms / 2,000 ms
コード長 1,751 bytes
コンパイル時間 5,390 ms
コンパイル使用メモリ 312,268 KB
実行使用メモリ 6,548 KB
最終ジャッジ日時 2024-02-10 10:23:07
合計ジャッジ時間 9,916 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
6,548 KB
testcase_01 AC 3 ms
6,548 KB
testcase_02 AC 8 ms
6,548 KB
testcase_03 AC 114 ms
6,548 KB
testcase_04 AC 154 ms
6,548 KB
testcase_05 AC 106 ms
6,548 KB
testcase_06 AC 114 ms
6,548 KB
testcase_07 AC 104 ms
6,548 KB
testcase_08 AC 103 ms
6,548 KB
testcase_09 AC 103 ms
6,548 KB
testcase_10 AC 142 ms
6,548 KB
testcase_11 AC 4 ms
6,548 KB
testcase_12 AC 157 ms
6,548 KB
testcase_13 AC 136 ms
6,548 KB
testcase_14 AC 143 ms
6,548 KB
testcase_15 AC 137 ms
6,548 KB
testcase_16 AC 136 ms
6,548 KB
testcase_17 AC 140 ms
6,548 KB
testcase_18 AC 137 ms
6,548 KB
testcase_19 AC 138 ms
6,548 KB
testcase_20 AC 152 ms
6,548 KB
testcase_21 AC 139 ms
6,548 KB
testcase_22 AC 138 ms
6,548 KB
testcase_23 AC 142 ms
6,548 KB
testcase_24 AC 139 ms
6,548 KB
testcase_25 AC 144 ms
6,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>

using namespace std;
using namespace atcoder;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<vi> vvi;
typedef vector<vll> vvll;

template <class T> using Vec = vector<T>;
template <class T> using Graph = Vec<Vec<T>>;

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,n-1,-1)
#define rrepi(i,a,b) for(int i=int(a);i>int(b);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep)(__VA_ARGS__)

#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define REVERSE(x) reverse(all(x))

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using mint = modint998244353;

mint op(mint a, mint b) { return a + b; }
mint e() { return 0; }

int main() {
    int N;
    cin >> N;

    int M = 1e5;

    vi A(N);
    rep(i, N) cin >> A[i];

    // segtree<mint, op, e> dp_prev(M+1);
    // dp_prev.set(0, 1);

    Vec<mint> dp_prev(M+1);
    dp_prev[0] = 1;

    rep(i, N) {
        Vec<mint> dp_next(M+1);
        Vec<mint> sum(M+2);
        rep(j, M+1) sum[j+1] = sum[j] + dp_prev[j];
        rep(j, A[i], M+1) {
            int l = (i>0) ? A[i-1] : 0;
            int r = (i>0) ? min(j, j+A[i-1]-A[i]) : j;
            if (!(l <= r)) continue;
            dp_next[j] = sum[r+1] - sum[l];
        }
        dp_prev = dp_next;
    }

    mint ans = 0;
    rep(i, M+1) ans += dp_prev[i];
    cout << ans.val() << endl;
}
0