結果

問題 No.1188 レベルX門松列
ユーザー titia
提出日時 2020-08-22 15:08:00
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 632 ms / 2,000 ms
コード長 907 bytes
コンパイル時間 158 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 42,240 KB
最終ジャッジ日時 2024-10-15 09:25:13
合計ジャッジ時間 8,476 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N=int(input())
A=list(map(int,input().split()))

compression_dict={a: ind for ind, a in enumerate(sorted(set(A)))}
A=[compression_dict[a] for a in A]

import bisect

DP=[float("inf")]*N # DP[i]で、長さiのLISの最終要素の最小値.
ANS1=[]

for a in A:
    pos=bisect.bisect_left(DP,a)
    DP[pos]=a

    ANS1.append(pos)

B=A[::-1]
DP=[float("inf")]*N
ANS2=[]

for a in B:
    pos=bisect.bisect_left(DP,a)
    DP[pos]=a

    ANS2.append(pos)

ANS2=ANS2[::-1]
MAX=max(A)
C=[MAX-a for a in A]

DP=[float("inf")]*N
ANS3=[]

for a in C:
    pos=bisect.bisect_left(DP,a)
    DP[pos]=a

    ANS3.append(pos)

D=C[::-1]
DP=[float("inf")]*N
ANS4=[]

for a in D:
    pos=bisect.bisect_left(DP,a)
    DP[pos]=a

    ANS4.append(pos)

ANS4=ANS4[::-1]

ANS=0
for i in range(N):
    ANS=max(ANS,min(ANS1[i],ANS2[i]))
    ANS=max(ANS,min(ANS3[i],ANS4[i]))

print(ANS)




0