結果

問題 No.2055 12x34...
ユーザー HIcoderHIcoder
提出日時 2023-07-11 18:01:39
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,230 bytes
コンパイル時間 1,391 ms
コンパイル使用メモリ 112,108 KB
実行使用メモリ 10,200 KB
最終ジャッジ日時 2023-10-11 09:07:59
合計ジャッジ時間 8,308 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
4,372 KB
testcase_02 WA -
testcase_03 TLE -
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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]=1;

    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];    
            dp[i]%=MOD;
        }

        dp[i]++;
        dp[i]%=MOD;
    }

    ll ans=0;
    for(int i=0;i<N;i++){
        //ans+=dp[i]-1;

        ans+=(dp[i]-1+MOD)%MOD;
        ans%=MOD;
    }
    cout<<ans<<endl;

}
0