結果
| 問題 |
No.2055 12x34...
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-07-11 18:17:51 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 346 ms / 2,000 ms |
| コード長 | 755 bytes |
| コンパイル時間 | 1,012 ms |
| コンパイル使用メモリ | 110,024 KB |
| 最終ジャッジ日時 | 2025-02-15 09:51:10 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 41 |
ソースコード
#include<iostream>
#include<set>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<numeric>
#include<queue>
#include<cmath>
using namespace std;
typedef long long ll;
const ll INF=1LL<<60;
typedef pair<int,int> P;
typedef pair<int,P> PP;
const ll MOD=998244353;
const double PI=acos(-1);
int main(){
int N;
cin>>N;
map<int,ll> mp;
vector<int> A(N);
for(int i=0;i<N;i++){
cin>>A[i];
}
vector<ll> dp(N+1,0);
ll ans=0;
for(int i=0;i<N;i++){
ans+=(mp[A[i]-1]+1)%MOD;//i番目から始めることに対する1通り
ans%=MOD;
mp[A[i]]+=(mp[A[i]-1]+1)%MOD;
mp[A[i]]%=MOD;
}
ans-=N;
ans+=MOD;
ans%=MOD;
cout<<ans<<endl;
}