結果
問題 |
No.2055 12x34...
|
ユーザー |
|
提出日時 | 2023-07-11 18:03:56 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,219 bytes |
コンパイル時間 | 945 ms |
コンパイル使用メモリ | 109,560 KB |
最終ジャッジ日時 | 2025-02-15 09:50:34 |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | WA * 1 TLE * 2 -- * 38 |
ソースコード
#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=1e9+7; const double PI=acos(-1); int main(){ int N; cin>>N; map<int,vector<int>> mp; vector<int> A(N); for(int i=0;i<N;i++){ cin>>A[i]; mp[A[i]].push_back(i); } vector<ll> dp(N+1,0); dp[0]=0; for(int i=1;i<N;i++){ /* //iより後に出現しているA[i]+1の個数 ll num1=mp[A[i]+1].end()-lower_bound(mp[A[i]+1].begin(),mp[A[i]+1].end(),i); auto it=lower_bound(mp[A[i]-1].begin(),mp[A[i]-1].end(),i); ll num2=it-mp[A[i]-1].begin();// iより前に出現しているA[i]-1の個数 */ for(int v:mp[A[i]-1]){ if(v>=i) break; //v<i dp[i]+=(dp[v]+1)%MOD; dp[i]%=MOD; } dp[i]%=MOD; } ll ans=0; for(int i=0;i<N;i++){ ans+=dp[i]; //ans+=(dp[i]-1+MOD)%MOD; ans%=MOD; } cout<<ans<<endl; }