結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 408 ms
18,564 KB
testcase_01 AC 423 ms
21,412 KB
testcase_02 AC 392 ms
19,996 KB
testcase_03 AC 529 ms
24,416 KB
testcase_04 AC 490 ms
29,896 KB
testcase_05 AC 31 ms
10,880 KB
testcase_06 WA -
testcase_07 AC 450 ms
29,708 KB
testcase_08 AC 452 ms
29,584 KB
testcase_09 WA -
testcase_10 AC 32 ms
10,880 KB
testcase_11 AC 65 ms
11,904 KB
testcase_12 AC 69 ms
12,032 KB
testcase_13 AC 72 ms
12,032 KB
testcase_14 AC 317 ms
17,520 KB
testcase_15 AC 515 ms
24,248 KB
testcase_16 AC 37 ms
11,008 KB
testcase_17 AC 409 ms
20,500 KB
testcase_18 AC 31 ms
10,880 KB
testcase_19 AC 390 ms
19,960 KB
testcase_20 AC 31 ms
11,008 KB
testcase_21 WA -
testcase_22 AC 31 ms
10,880 KB
testcase_23 WA -
権限があれば一括ダウンロードができます

ソースコード

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=1
for i in range(n):
	ans=max(ans,min(LI[i],RI[n-1-i]),min(LD[i],RD[n-1-i]))
print(ans)
0