結果

問題 No.1188 レベルX門松列
ユーザー kotatsugamekotatsugame
提出日時 2020-08-22 15:44:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 654 bytes
コンパイル時間 471 ms
コンパイル使用メモリ 68,704 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-23 10:00:52
合計ジャッジ時間 1,993 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 49 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 WA -
testcase_07 AC 47 ms
5,376 KB
testcase_08 AC 46 ms
5,504 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 6 ms
5,376 KB
testcase_12 WA -
testcase_13 AC 6 ms
5,376 KB
testcase_14 AC 39 ms
5,376 KB
testcase_15 AC 64 ms
5,632 KB
testcase_16 AC 3 ms
5,376 KB
testcase_17 AC 51 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 46 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 1 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:39:1: warning: ISO C++ forbids declaration of 'main' with no type [-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=upper_bound(L,L+N,A[i])-L;
		L[id]=A[i];
		X[i]=id;
	}
	R[0]=-2e9;
	for(int i=N;i--;)
	{
		int id=upper_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