結果

問題 No.1188 レベルX門松列
ユーザー takakintakakin
提出日時 2020-08-22 23:46:26
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 819 bytes
コンパイル時間 106 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 29,944 KB
最終ジャッジ日時 2024-04-23 12:30:10
合計ジャッジ時間 6,839 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 31 ms
10,880 KB
testcase_06 AC 351 ms
14,740 KB
testcase_07 AC 426 ms
29,716 KB
testcase_08 AC 418 ms
29,456 KB
testcase_09 AC 31 ms
11,008 KB
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 AC 30 ms
11,008 KB
testcase_21 AC 31 ms
10,752 KB
testcase_22 AC 31 ms
10,880 KB
testcase_23 AC 31 ms
11,008 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=lambda: sys.stdin.readline().rstrip()
import bisect
n=int(input())
A=[int(i) for i in input().split()]
LI,LD=[0]*n,[0]*n
I,D=[A[0]],[-A[0]]
il,dl=1,1
for i in range(1,n):
	a=A[i]
	if I[-1]<a:
		LI[i]=il
		il+=1
		I.append(a)
	else:
		ind_i=bisect.bisect_left(I,a)
		LI[i]=ind_i
		I[ind_i]=a
	if D[-1]<-a:
		LD[i]=dl
		dl+=1
		D.append(-a)
	else:
		ind_d=bisect.bisect_left(D,-a)
		LD[i]=ind_d
		D[ind_d]=-a

RI,RD=[0]*n,[0]*n
I,D=[A[-1]],[-A[-1]]
ir,dr=1,1
for i in range(1,n):
	a=A[n-1-i]
	if I[-1]<a:
		RI[i]=ir
		ir+=1
		I.append(a)
	else:
		ind_i=bisect.bisect_left(I,a)
		RI[i]=ind_i
		I[ind_i]=a
	if D[-1]<-a:
		RD[i]=dr
		dr+=1
		D.append(-a)
	else:
		ind_d=bisect.bisect_left(D,-a)
		RD[i]=ind_d
		D[ind_d]=-a

ans=0
for i in range(n):
	ans=max(ans,min(LI[i],RI[i]),min(LD[i],RD[i]))
print(ans)
0