結果

問題 No.1188 レベルX門松列
ユーザー rlangevinrlangevin
提出日時 2023-01-18 00:35:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 228 ms / 2,000 ms
コード長 652 bytes
コンパイル時間 312 ms
コンパイル使用メモリ 87,084 KB
実行使用メモリ 93,828 KB
最終ジャッジ日時 2023-09-01 21:54:31
合計ジャッジ時間 6,488 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 168 ms
90,616 KB
testcase_01 AC 206 ms
88,776 KB
testcase_02 AC 202 ms
87,376 KB
testcase_03 AC 227 ms
90,928 KB
testcase_04 AC 210 ms
93,328 KB
testcase_05 AC 72 ms
71,292 KB
testcase_06 AC 150 ms
89,340 KB
testcase_07 AC 208 ms
93,828 KB
testcase_08 AC 207 ms
92,912 KB
testcase_09 AC 70 ms
71,160 KB
testcase_10 AC 71 ms
71,408 KB
testcase_11 AC 118 ms
77,880 KB
testcase_12 AC 118 ms
78,028 KB
testcase_13 AC 118 ms
77,732 KB
testcase_14 AC 179 ms
84,848 KB
testcase_15 AC 228 ms
91,672 KB
testcase_16 AC 96 ms
77,268 KB
testcase_17 AC 204 ms
87,900 KB
testcase_18 AC 70 ms
71,288 KB
testcase_19 AC 197 ms
87,496 KB
testcase_20 AC 69 ms
71,460 KB
testcase_21 AC 70 ms
71,220 KB
testcase_22 AC 69 ms
71,300 KB
testcase_23 AC 69 ms
70,964 KB
権限があれば一括ダウンロードができます

ソースコード

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])
        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 = 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]))
    ans = max(ans, min(LD[i], RD[i]))
print(ans)
0