結果

問題 No.1188 レベルX門松列
ユーザー 37zigen
提出日時 2020-08-25 09:52:16
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 364 ms / 2,000 ms
コード長 457 bytes
コンパイル時間 172 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 24,080 KB
最終ジャッジ日時 2024-11-06 11:06:17
合計ジャッジ時間 5,539 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect
N=int(input())
A=list(map(int,input().split()))
def f(n,a):
    ret=0
    def g(n,a):
        dp=[10**20]*n
        A=[0]*n
        for i in range(n):
            to=bisect.bisect_left(dp,a[i])
            dp[to]=a[i]
            A[i]=to
        return A
    L=g(n,a)
    R=g(n,a[::-1])[::-1]
    for i in range(n):
        ret=max(ret,min(L[i],R[i]))
    return ret

ans=f(N,A)
for i in range(N):
    A[i]=-A[i]
ans=max(ans,f(N,A))
print(ans)
0