結果

問題 No.2625 Bouns Ai
ユーザー maksim
提出日時 2024-02-09 22:12:46
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 130 ms / 2,000 ms
コード長 909 bytes
コンパイル時間 1,375 ms
コンパイル使用メモリ 168,180 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-09-28 15:28:29
合計ジャッジ時間 4,632 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
#define int long long
#define all(x) x.begin(), x.end()
#define app push_back
#ifdef LOCAL
#define debug(...) [](auto...a){ ((cout << a << ' '), ...) << '\n';}(#__VA_ARGS__, ":", __VA_ARGS__)
#else
#define debug(...)
#endif
const int p=998244353;
const int maxn=1e5+5;
int dp[maxn];int pr[maxn];
int dp2[maxn];
int32_t main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;cin>>n;int a[n];for(int i=0;i<n;++i) cin>>a[i];
    dp[0]=1;for(int i=1;i<maxn;++i) {pr[i]=pr[i-1]+dp[i-1];pr[i]%=p;}
    for(int j=0;j<n;++j)
    {
        fill(dp2,dp2+maxn,0LL);
        for(int k=a[j];k<=100000;++k)
        {
            int mx=0;if(j) mx=max(0LL,a[j]-a[j-1]);
            dp2[k]=pr[max(0LL,k-mx+1)];
        }
        copy(dp2,dp2+maxn,dp);for(int i=1;i<maxn;++i) {pr[i]=pr[i-1]+dp[i-1];pr[i]%=p;}
    }
    cout<<pr[maxn-1];
    return 0;
}
0