結果

問題 No.1188 レベルX門松列
ユーザー rlangevinrlangevin
提出日時 2023-01-17 23:59:57
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 742 bytes
コンパイル時間 587 ms
コンパイル使用メモリ 87,376 KB
実行使用メモリ 94,080 KB
最終ジャッジ日時 2023-09-01 03:46:33
合計ジャッジ時間 5,865 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 205 ms
89,160 KB
testcase_02 AC 195 ms
87,528 KB
testcase_03 AC 223 ms
90,948 KB
testcase_04 AC 206 ms
93,552 KB
testcase_05 AC 69 ms
71,584 KB
testcase_06 AC 147 ms
89,696 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 70 ms
71,628 KB
testcase_10 AC 70 ms
71,360 KB
testcase_11 AC 112 ms
77,996 KB
testcase_12 AC 113 ms
78,244 KB
testcase_13 AC 114 ms
78,016 KB
testcase_14 AC 179 ms
85,408 KB
testcase_15 AC 226 ms
91,708 KB
testcase_16 AC 94 ms
77,288 KB
testcase_17 AC 197 ms
88,024 KB
testcase_18 AC 70 ms
71,316 KB
testcase_19 AC 194 ms
87,996 KB
testcase_20 AC 70 ms
71,168 KB
testcase_21 AC 70 ms
71,460 KB
testcase_22 AC 69 ms
71,324 KB
testcase_23 AC 70 ms
71,288 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])
            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