結果

問題 No.1188 レベルX門松列
ユーザー kotatsugamekotatsugame
提出日時 2020-08-22 15:45:55
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 63 ms / 2,000 ms
コード長 654 bytes
コンパイル時間 529 ms
コンパイル使用メモリ 66,928 KB
実行使用メモリ 5,312 KB
最終ジャッジ日時 2023-08-05 12:48:41
合計ジャッジ時間 2,323 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
5,240 KB
testcase_01 AC 48 ms
4,904 KB
testcase_02 AC 40 ms
4,744 KB
testcase_03 AC 56 ms
5,312 KB
testcase_04 AC 47 ms
5,256 KB
testcase_05 AC 2 ms
4,388 KB
testcase_06 AC 24 ms
5,240 KB
testcase_07 AC 47 ms
5,284 KB
testcase_08 AC 47 ms
5,232 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 6 ms
4,376 KB
testcase_12 AC 5 ms
4,380 KB
testcase_13 AC 6 ms
4,376 KB
testcase_14 AC 38 ms
4,504 KB
testcase_15 AC 63 ms
5,240 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 49 ms
4,884 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 47 ms
4,800 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:39:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
   39 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<algorithm>
using namespace std;
int N;
int A[1<<17];
int L[1<<17],R[1<<17];
int X[1<<17],Y[1<<17];
int calc()
{
	for(int i=0;i<=N;i++)
	{
		L[i]=2e9;
		R[i]=2e9;
	}
	L[0]=-2e9;
	for(int i=0;i<N;i++)
	{
		int id=lower_bound(L,L+N,A[i])-L;
		L[id]=A[i];
		X[i]=id;
	}
	R[0]=-2e9;
	for(int i=N;i--;)
	{
		int id=lower_bound(R,R+N,A[i])-R;
		R[id]=A[i];
		Y[i]=id;
	}
	int Rm=0;
	int ans=0;
	for(int i=N;i--;)
	{
		if(Rm<Y[i])Rm=Y[i];
		int x=Rm<X[i]?Rm:X[i];
		if(ans<x-1)ans=x-1;
	}
	return ans;
}
main()
{
	cin>>N;
	for(int i=0;i<N;i++)cin>>A[i];
	int ans=calc();
	for(int i=0;i<N;i++)A[i]*=-1;
	cout<<max(ans,calc())<<endl;
}
0