結果

問題 No.1188 レベルX門松列
ユーザー rlangevinrlangevin
提出日時 2023-01-17 23:58:26
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 743 bytes
コンパイル時間 317 ms
コンパイル使用メモリ 87,192 KB
実行使用メモリ 98,092 KB
最終ジャッジ日時 2023-09-01 03:45:50
合計ジャッジ時間 5,822 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 218 ms
93,760 KB
testcase_05 AC 74 ms
71,336 KB
testcase_06 WA -
testcase_07 AC 205 ms
92,400 KB
testcase_08 AC 205 ms
92,116 KB
testcase_09 AC 72 ms
71,272 KB
testcase_10 AC 75 ms
71,448 KB
testcase_11 AC 119 ms
77,964 KB
testcase_12 WA -
testcase_13 AC 121 ms
78,300 KB
testcase_14 AC 186 ms
85,204 KB
testcase_15 AC 236 ms
91,732 KB
testcase_16 AC 105 ms
77,512 KB
testcase_17 AC 214 ms
87,864 KB
testcase_18 AC 75 ms
71,364 KB
testcase_19 AC 211 ms
88,008 KB
testcase_20 AC 72 ms
71,472 KB
testcase_21 AC 73 ms
71,420 KB
testcase_22 AC 74 ms
71,396 KB
testcase_23 AC 73 ms
71,384 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_right(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