結果

問題 No.2625 Bouns Ai
ユーザー Nzt3Nzt3
提出日時 2024-02-09 23:08:45
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 221 ms / 2,000 ms
コード長 762 bytes
コンパイル時間 2,017 ms
コンパイル使用メモリ 206,000 KB
実行使用メモリ 82,048 KB
最終ジャッジ日時 2024-02-09 23:08:56
合計ジャッジ時間 7,315 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
6,676 KB
testcase_01 AC 3 ms
6,676 KB
testcase_02 AC 10 ms
7,168 KB
testcase_03 AC 195 ms
82,048 KB
testcase_04 AC 221 ms
82,048 KB
testcase_05 AC 195 ms
82,048 KB
testcase_06 AC 194 ms
82,048 KB
testcase_07 AC 196 ms
82,048 KB
testcase_08 AC 193 ms
82,048 KB
testcase_09 AC 194 ms
82,048 KB
testcase_10 AC 217 ms
82,048 KB
testcase_11 AC 5 ms
6,676 KB
testcase_12 AC 193 ms
82,048 KB
testcase_13 AC 193 ms
82,048 KB
testcase_14 AC 193 ms
82,048 KB
testcase_15 AC 198 ms
82,048 KB
testcase_16 AC 194 ms
82,048 KB
testcase_17 AC 196 ms
82,048 KB
testcase_18 AC 194 ms
82,048 KB
testcase_19 AC 195 ms
82,048 KB
testcase_20 AC 196 ms
82,048 KB
testcase_21 AC 196 ms
82,048 KB
testcase_22 AC 196 ms
82,048 KB
testcase_23 AC 198 ms
82,048 KB
testcase_24 AC 195 ms
82,048 KB
testcase_25 AC 193 ms
82,048 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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';
}
0