結果

問題 No.992 最長増加部分列の数え上げ
ユーザー %20%20
提出日時 2020-02-05 23:55:25
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 48 ms / 2,000 ms
コード長 768 bytes
コンパイル時間 2,926 ms
コンパイル使用メモリ 215,512 KB
実行使用メモリ 7,260 KB
最終ジャッジ日時 2023-10-25 22:44:07
合計ジャッジ時間 5,908 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 19 ms
4,736 KB
testcase_05 AC 15 ms
4,552 KB
testcase_06 AC 23 ms
5,028 KB
testcase_07 AC 18 ms
4,608 KB
testcase_08 AC 10 ms
4,348 KB
testcase_09 AC 18 ms
4,836 KB
testcase_10 AC 23 ms
4,944 KB
testcase_11 AC 29 ms
5,436 KB
testcase_12 AC 8 ms
4,348 KB
testcase_13 AC 17 ms
4,668 KB
testcase_14 AC 17 ms
4,620 KB
testcase_15 AC 7 ms
4,348 KB
testcase_16 AC 44 ms
6,964 KB
testcase_17 AC 10 ms
4,348 KB
testcase_18 AC 16 ms
4,496 KB
testcase_19 AC 29 ms
5,264 KB
testcase_20 AC 48 ms
7,112 KB
testcase_21 AC 48 ms
7,112 KB
testcase_22 AC 48 ms
7,260 KB
testcase_23 AC 47 ms
7,112 KB
testcase_24 AC 48 ms
7,224 KB
testcase_25 AC 48 ms
7,112 KB
testcase_26 AC 48 ms
7,112 KB
testcase_27 AC 48 ms
7,204 KB
testcase_28 AC 48 ms
7,236 KB
testcase_29 AC 48 ms
7,256 KB
testcase_30 AC 34 ms
6,192 KB
testcase_31 AC 34 ms
6,032 KB
testcase_32 AC 33 ms
6,036 KB
testcase_33 AC 33 ms
6,192 KB
testcase_34 AC 33 ms
5,904 KB
testcase_35 AC 32 ms
6,404 KB
testcase_36 AC 32 ms
6,404 KB
testcase_37 AC 32 ms
6,404 KB
testcase_38 AC 32 ms
6,404 KB
testcase_39 AC 32 ms
6,404 KB
testcase_40 AC 33 ms
6,636 KB
testcase_41 AC 32 ms
6,620 KB
testcase_42 AC 33 ms
6,496 KB
testcase_43 AC 33 ms
6,412 KB
testcase_44 AC 33 ms
6,864 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

#define all(v) v.begin(),v.end()

const int inf=2e9;
const int MD=1e9+7;

int main(){cin.tie(0);ios::sync_with_stdio(false);
	int N;cin>>N;
	assert(1<=N&&N<=200000);
	vector<int>dp1={-inf};
	vector<vector<int>>dp2={{inf,-inf}};
	vector<vector<long long>>dp4={{0,1}};
	for(int _=0;_<N;++_){
		int A;cin>>A;
		assert(-1000000000<=A&&A<=1000000000);
		int x=lower_bound(all(dp1),A)-dp1.begin();
		if(x==dp1.size()){
			dp1.push_back(A);
			dp2.push_back({inf});
			dp4.push_back({0});
		}else{
			dp1[x]=A;
		}
		dp2[x].push_back(A);
		int y=upper_bound(all(dp2[x-1]),A,greater<int>())-dp2[x-1].begin()-1;
		dp4[x].push_back((dp4[x].back()+dp4[x-1].back()-dp4[x-1][y]+MD)%MD);
	}
	cout<<dp4.back().back()<<"\n";
	return 0;
}
0