結果

問題 No.1188 レベルX門松列
ユーザー lemondolemondo
提出日時 2020-08-22 15:18:33
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 788 bytes
コンパイル時間 204 ms
コンパイル使用メモリ 81,968 KB
実行使用メモリ 92,288 KB
最終ジャッジ日時 2024-04-23 09:39:48
合計ジャッジ時間 4,032 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 184 ms
89,216 KB
testcase_02 AC 166 ms
87,928 KB
testcase_03 AC 192 ms
91,300 KB
testcase_04 AC 187 ms
91,432 KB
testcase_05 AC 41 ms
52,608 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 39 ms
52,352 KB
testcase_10 AC 41 ms
52,224 KB
testcase_11 AC 91 ms
76,840 KB
testcase_12 AC 90 ms
76,420 KB
testcase_13 AC 92 ms
76,500 KB
testcase_14 AC 150 ms
85,120 KB
testcase_15 AC 196 ms
92,288 KB
testcase_16 AC 70 ms
71,040 KB
testcase_17 AC 171 ms
88,332 KB
testcase_18 AC 40 ms
52,480 KB
testcase_19 AC 168 ms
87,936 KB
testcase_20 AC 40 ms
52,224 KB
testcase_21 AC 40 ms
52,608 KB
testcase_22 AC 40 ms
51,840 KB
testcase_23 AC 40 ms
52,736 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
As = list(mapint())
from bisect import bisect_left

def LIS(in_lis):
    lis = []
    ret_lis = [0]*len(in_lis)
    for i in range(N):
        a = in_lis[i]
        idx = bisect_left(lis, a)
        if idx>=len(lis):
            lis.append(a)
            ret_lis[i] = len(lis)
        else:
            lis[idx] = a
    return ret_lis

ascending = LIS(As)
decending = LIS([-a for a in As])
r_ascending = LIS(As[::-1])[::-1]
r_decending = LIS([-a for a in As[::-1]])[::-1]
ans = 0
for n, r in zip(ascending, r_ascending):
    ans = max(ans, min(n, r))
for n, r in zip(decending, r_decending):
    ans = max(ans, min(n, r))
print(ans-1)
0