結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 372 ms
18,580 KB
testcase_01 AC 401 ms
21,348 KB
testcase_02 AC 386 ms
20,124 KB
testcase_03 AC 498 ms
24,412 KB
testcase_04 AC 447 ms
30,032 KB
testcase_05 AC 28 ms
11,008 KB
testcase_06 AC 342 ms
14,740 KB
testcase_07 AC 411 ms
29,584 KB
testcase_08 AC 390 ms
29,452 KB
testcase_09 AC 27 ms
10,880 KB
testcase_10 AC 28 ms
10,880 KB
testcase_11 AC 59 ms
11,776 KB
testcase_12 AC 61 ms
12,032 KB
testcase_13 AC 62 ms
11,904 KB
testcase_14 AC 289 ms
17,528 KB
testcase_15 AC 482 ms
24,120 KB
testcase_16 AC 32 ms
11,008 KB
testcase_17 AC 388 ms
20,368 KB
testcase_18 AC 29 ms
10,880 KB
testcase_19 AC 358 ms
19,960 KB
testcase_20 AC 29 ms
10,880 KB
testcase_21 AC 28 ms
10,880 KB
testcase_22 AC 27 ms
10,880 KB
testcase_23 AC 27 ms
10,880 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[n-1-i]),min(LD[i],RD[n-1-i]))
print(ans)
0