結果

問題 No.1188 レベルX門松列
ユーザー 👑 rin204rin204
提出日時 2022-01-18 22:12:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 214 ms / 2,000 ms
コード長 672 bytes
コンパイル時間 434 ms
コンパイル使用メモリ 86,932 KB
実行使用メモリ 91,956 KB
最終ジャッジ日時 2023-08-15 07:40:39
合計ジャッジ時間 4,712 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 148 ms
91,024 KB
testcase_01 AC 185 ms
89,148 KB
testcase_02 AC 182 ms
87,680 KB
testcase_03 AC 206 ms
91,276 KB
testcase_04 AC 195 ms
91,472 KB
testcase_05 AC 69 ms
71,020 KB
testcase_06 AC 140 ms
89,968 KB
testcase_07 AC 201 ms
90,960 KB
testcase_08 AC 204 ms
90,964 KB
testcase_09 AC 67 ms
71,212 KB
testcase_10 AC 69 ms
71,200 KB
testcase_11 AC 121 ms
77,684 KB
testcase_12 AC 118 ms
78,072 KB
testcase_13 AC 117 ms
78,220 KB
testcase_14 AC 167 ms
85,220 KB
testcase_15 AC 214 ms
91,956 KB
testcase_16 AC 92 ms
76,868 KB
testcase_17 AC 187 ms
88,392 KB
testcase_18 AC 71 ms
71,096 KB
testcase_19 AC 186 ms
88,208 KB
testcase_20 AC 66 ms
71,148 KB
testcase_21 AC 67 ms
71,092 KB
testcase_22 AC 68 ms
71,072 KB
testcase_23 AC 67 ms
70,968 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import bisect_left

n = int(input())
A = list(map(int, input().split()))
ans = 0
for _ in range(2):
    left = [-1] * n
    lst = []
    for i, a in enumerate(A):
        p = bisect_left(lst, a)
        left[i] = p
        if len(lst) == p:
            lst.append(a)
        else:
            lst[p] = a
            
    right = [-1] * n
    lst = []
    for i in range(n - 1, -1, -1):
        a = A[i]
        p = bisect_left(lst, a)
        right[i] = p
        if len(lst) == p:
            lst.append(a)
        else:
            lst[p] = a
            
    for l, r in zip(left, right):
        ans = max(ans, min(l, r))
    A = [-a for a in A]
print(ans)
0