結果

問題 No.1188 レベルX門松列
ユーザー rlangevin
提出日時 2023-01-17 23:59:57
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 742 bytes
コンパイル時間 325 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 92,668 KB
最終ジャッジ日時 2025-01-03 06:04:42
合計ジャッジ時間 4,620 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import *

def LIS(A):
    # weakly increase --> bisect_right
    # strictly increase --> bisect_left
    data = []
    L = []
    for i in range(N):
        ind = bisect_left(data, A[i])
        flag = 0
        if len(data) == ind:
            data.append(A[i])
            flag = 1
        else:
            data[ind] = A[i]
        if flag:
            L.append(len(data))
        else:
            L.append(0)
    return L


N = int(input())
A = list(map(int, input().split()))
LU = LIS(A)
A.reverse()
RU = LIS(A)
RU.reverse()
A = list(map(lambda x : -x, 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])-1)
    ans = max(ans, min(LD[i], RD[i])-1)
print(ans)
0