結果
| 問題 |
No.2625 Bouns Ai
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-02-09 23:09:47 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 328 ms / 2,000 ms |
| コード長 | 1,031 bytes |
| コンパイル時間 | 2,004 ms |
| コンパイル使用メモリ | 197,620 KB |
| 最終ジャッジ日時 | 2025-02-19 04:11:01 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 998244353;
void solve() {
ll N;
cin >> N;
vector<ll> A(N);
for (int i = 0; i < N; i++) cin >> A[i];
vector<vector<ll>> dp(N, vector<ll>((int)1e+5 + 2, 0));
dp[0][0] = 1;
for (int i = 0; i < N; i++) {
for (int j = 0; j <= (int)1e+5; j++) dp[i][j+1] = (dp[i][j+1] + dp[i][j]) % MOD;
if (i == N-1) break;
int B = 1e+5 - A[i+1];
for (int j = 0; j <= (int)1e+5; j++) {
int x = max((ll)j, A[i] + j - A[i+1]);
if (x <= B) {
dp[i+1][x] = (dp[i+1][x] + dp[i][j]) % MOD;
dp[i+1][B+1] = (dp[i+1][B+1] - dp[i][j] + MOD) % MOD;
}
}
}
ll ans = 0;
for (int j = 0; j <= (int)1e+5; j++) ans = (ans + dp[N-1][j]) % MOD;
cout << ans << "\n";
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout << fixed << setprecision(15);
int T = 1;
// cin >> T;
while (T--) solve();
}