結果

問題 No.992 最長増加部分列の数え上げ
ユーザー 👑 NachiaNachia
提出日時 2020-12-10 23:11:33
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 723 bytes
コンパイル時間 2,548 ms
コンパイル使用メモリ 205,036 KB
実行使用メモリ 7,160 KB
最終ジャッジ日時 2023-10-20 01:00:21
合計ジャッジ時間 8,072 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using LL=long long;
using ULL=unsigned long long;
#define rep(i,n) for(int i=0;i<(n);i++)

const ULL M=1000000007;

int main(){
  int N; cin>>N;
  vector<int> A(N); rep(i,N) cin>>A[i];
  vector<int> lisT(N+1,1000000001);
  vector<int> I(N);
  int p=0;
  rep(i,N){
    int l=0, r=N+1;
    while(r-l>1){
      int m=(l+r)/2;
      if(lisT[m-1]<A[i]) l=m; else r=m;
    }
    lisT[l]=A[i];
    I[i]=l+1;
    p=max(p,l+1);
  }
  vector<int> pre(p+1,-1);
  pre[0]=0;
  vector<ULL> dp(N+1);
  dp[0]=1;
  rep(i,N){
    if(pre[I[i]]!=-1) dp[i+1]+=dp[pre[I[i]]];
    if(pre[I[i]-1]!=-1) dp[i+1]+=dp[pre[I[i]-1]];
    dp[i+1]%=M;
    pre[I[i]]=i+1;
  }
  cout<<dp[N]<<endl;
  return 0;
}
0