結果

問題 No.1188 レベルX門松列
ユーザー yansi819
提出日時 2024-05-06 18:01:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 201 ms / 2,000 ms
コード長 545 bytes
コンパイル時間 216 ms
コンパイル使用メモリ 81,844 KB
実行使用メモリ 91,780 KB
最終ジャッジ日時 2024-11-29 02:33:04
合計ジャッジ時間 4,432 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import *

def LIS(A):
    data = []
    L = []
    for i in range(N):
        ind = bisect_left(data, A[i])
        if len(data) == ind:
            data.append(A[i])
        else:
            data[ind] = A[i]
        L.append(ind)
    return L

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

LU = LIS(A)
A.reverse()
RU = LIS(A)
RU.reverse()
A = [-a for a in A]
RD = LIS(A)
RD.reverse()
A.reverse()
LD = LIS(A)

ans = 0
for i in range(N):
    ans = max(ans, min(LU[i], RU[i]))
    ans = max(ans, min(LD[i], RD[i]))

print(ans)
0