結果
問題 | No.2625 Bouns Ai |
ユーザー | Nzt3 |
提出日時 | 2024-02-09 23:08:45 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 186 ms / 2,000 ms |
コード長 | 762 bytes |
コンパイル時間 | 1,895 ms |
コンパイル使用メモリ | 206,544 KB |
実行使用メモリ | 82,048 KB |
最終ジャッジ日時 | 2024-09-28 16:20:23 |
合計ジャッジ時間 | 6,610 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
#include<bits/stdc++.h> using namespace std; using ll=long long; constexpr int MOD=998244353; const int MAX_A=100001; void ch(int &a,int b){ a=(a+b)%MOD; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int N; cin>>N; vector A(N,0); for(int &i:A)cin>>i; vector dp(N,vector(MAX_A,0)); for(int i=0;i<MAX_A;i++){ if(i+A[0]<MAX_A){ dp[0][i]=1; } } for(int i=1;i<N;i++){ for(int j=0;j<MAX_A-1;j++){ ch(dp[i-1][j+1],dp[i-1][j]); } int t=A[i-1]-A[i]; for(int j=0;j<MAX_A;j++){ int c=min(j,j-t); if(c>=0&&c<MAX_A){ ch(dp[i][j],dp[i-1][c]); } } } int ans=0; for(int i=0;i<MAX_A;i++){ if(i+A[N-1]<MAX_A){ ch(ans,dp[N-1][i]); } } cout<<ans<<'\n'; }