結果

問題 No.1188 レベルX門松列
ユーザー hir355hir355
提出日時 2020-08-22 13:56:46
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 821 bytes
コンパイル時間 406 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 27,296 KB
最終ジャッジ日時 2024-04-23 08:23:11
合計ジャッジ時間 7,007 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 436 ms
18,996 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 412 ms
15,496 KB
testcase_07 AC 459 ms
27,296 KB
testcase_08 AC 454 ms
24,164 KB
testcase_09 AC 31 ms
11,008 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 30 ms
11,008 KB
testcase_21 AC 31 ms
10,880 KB
testcase_22 AC 31 ms
10,880 KB
testcase_23 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import bisect_left
INF = 10 ** 10
ans = 0
n = int(input())
a = list(map(int, input().split()))
ic = [0] * n
dc = [0] * n
dp = [INF] * (n + 1)
dp[0] = -INF
for i, x in enumerate(a):
    idx = bisect_left(dp, x)
    dp[idx] = x
    ic[i] = idx
dp = [INF] * (n + 1)
dp[0] = -INF
for i, x in enumerate(a[::-1]):
    idx = bisect_left(dp, x)
    dp[idx] = x
    dc[n - i - 1] = idx
for i in range(n):
    ans = max(ans, ic[i], dc[i])
a = list(map(lambda x: -x, a))
ic = [0] * n
dc = [0] * n
dp = [INF] * (n + 1)
dp[0] = -INF
for i, x in enumerate(a):
    idx = bisect_left(dp, x)
    dp[idx] = x
    ic[i] = idx
dp = [INF] * (n + 1)
dp[0] = -INF
for i, x in enumerate(a[::-1]):
    idx = bisect_left(dp, x)
    dp[idx] = x
    dc[n - i - 1] = idx
for i in range(n):
    ans = max(ans, ic[i], dc[i])
print(ans - 1)
0