結果

問題 No.992 最長増加部分列の数え上げ
ユーザー kotatsugamekotatsugame
提出日時 2020-02-07 06:12:54
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 182 ms / 2,000 ms
コード長 792 bytes
コンパイル時間 780 ms
コンパイル使用メモリ 73,780 KB
実行使用メモリ 32,196 KB
最終ジャッジ日時 2023-10-25 22:58:33
合計ジャッジ時間 8,236 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
15,896 KB
testcase_01 AC 5 ms
15,896 KB
testcase_02 AC 5 ms
15,896 KB
testcase_03 AC 5 ms
15,896 KB
testcase_04 AC 70 ms
22,080 KB
testcase_05 AC 53 ms
20,568 KB
testcase_06 AC 87 ms
23,388 KB
testcase_07 AC 63 ms
21,444 KB
testcase_08 AC 35 ms
18,908 KB
testcase_09 AC 65 ms
21,620 KB
testcase_10 AC 85 ms
23,364 KB
testcase_11 AC 106 ms
25,372 KB
testcase_12 AC 26 ms
17,844 KB
testcase_13 AC 60 ms
21,276 KB
testcase_14 AC 61 ms
21,288 KB
testcase_15 AC 26 ms
17,880 KB
testcase_16 AC 163 ms
30,736 KB
testcase_17 AC 36 ms
18,912 KB
testcase_18 AC 61 ms
21,152 KB
testcase_19 AC 108 ms
25,284 KB
testcase_20 AC 180 ms
32,196 KB
testcase_21 AC 179 ms
32,188 KB
testcase_22 AC 180 ms
32,188 KB
testcase_23 AC 180 ms
32,172 KB
testcase_24 AC 181 ms
32,156 KB
testcase_25 AC 180 ms
32,164 KB
testcase_26 AC 180 ms
32,172 KB
testcase_27 AC 179 ms
32,120 KB
testcase_28 AC 182 ms
32,168 KB
testcase_29 AC 180 ms
32,184 KB
testcase_30 AC 172 ms
31,080 KB
testcase_31 AC 171 ms
30,920 KB
testcase_32 AC 172 ms
30,924 KB
testcase_33 AC 171 ms
31,080 KB
testcase_34 AC 172 ms
30,792 KB
testcase_35 AC 169 ms
31,292 KB
testcase_36 AC 169 ms
31,292 KB
testcase_37 AC 172 ms
31,292 KB
testcase_38 AC 171 ms
31,292 KB
testcase_39 AC 169 ms
31,292 KB
testcase_40 AC 172 ms
31,524 KB
testcase_41 AC 170 ms
31,508 KB
testcase_42 AC 170 ms
31,384 KB
testcase_43 AC 170 ms
31,300 KB
testcase_44 AC 172 ms
31,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
using namespace std;
int N;
vector<int>s[2<<17];
vector<long>ss[2<<17];
long mod=1e9+7;
int main()
{
	cin>>N;
	for(int i=0;i<=N;i++)
	{
		s[i].push_back(2e9);
		ss[i].push_back(0);
	}
	s[0].push_back(-2e9);
	ss[0].push_back(1);
	for(int i=0;i<N;i++)
	{
		int A;cin>>A;
		int id;
		{
			int l=0,r=N+1;
			while(r-l>1)
			{
				int m=l+r>>1;
				if(s[m].back()>=A)r=m;
				else l=m;
			}
			id=r;
		}
		long now=ss[id-1].back();
		{
			int l=0,r=ss[id-1].size();
			while(r-l>1)
			{
				int m=l+r>>1;
				if(s[id-1][m]>=A)l=m;
				else r=m;
			}
			now-=ss[id-1][l];
		}
		s[id].push_back(A);
		now+=ss[id].back();
		ss[id].push_back((now%mod+mod)%mod);
	}
	for(int i=N;i;i--)
	{
		if(s[i].back()<2e9)
		{
			cout<<ss[i].back()<<endl;
			return 0;
		}
	}
}
0