結果

問題 No.2055 12x34...
ユーザー ripity
提出日時 2022-10-31 23:33:01
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 274 ms / 2,000 ms
コード長 513 bytes
コンパイル時間 2,138 ms
コンパイル使用メモリ 200,824 KB
最終ジャッジ日時 2025-02-08 16:26:56
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    constexpr int P = 998244353;
    cin >> N;
    vector<int> A(N), dp(N, 1);
    unordered_map<int, int> dp_sum;
    for( int i = 0; i < N; i++ ) {
        cin >> A[i];
    }
    for( int i = 0; i < N; i++ ) {
        dp[i] += dp_sum[A[i]-1];
        dp_sum[A[i]] += dp[i]%P;
        dp_sum[A[i]] %= P;
    }
    int ans = P-N;
    for( auto& [key, value] : dp_sum ) {
        ans += value;
        ans %= P;
    }
    cout << ans << endl;
}
0