結果

問題 No.1188 レベルX門松列
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2020-08-22 13:56:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 216 ms / 2,000 ms
コード長 909 bytes
コンパイル時間 207 ms
コンパイル使用メモリ 82,312 KB
実行使用メモリ 93,084 KB
最終ジャッジ日時 2024-04-23 08:22:32
合計ジャッジ時間 4,494 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 153 ms
89,256 KB
testcase_01 AC 194 ms
87,672 KB
testcase_02 AC 186 ms
85,824 KB
testcase_03 AC 215 ms
89,432 KB
testcase_04 AC 206 ms
93,084 KB
testcase_05 AC 40 ms
53,424 KB
testcase_06 AC 141 ms
88,328 KB
testcase_07 AC 204 ms
92,176 KB
testcase_08 AC 202 ms
92,928 KB
testcase_09 AC 40 ms
53,356 KB
testcase_10 AC 39 ms
53,268 KB
testcase_11 AC 97 ms
76,648 KB
testcase_12 AC 99 ms
76,588 KB
testcase_13 AC 98 ms
76,796 KB
testcase_14 AC 162 ms
83,332 KB
testcase_15 AC 216 ms
90,236 KB
testcase_16 AC 70 ms
72,572 KB
testcase_17 AC 184 ms
86,316 KB
testcase_18 AC 40 ms
53,084 KB
testcase_19 AC 180 ms
86,160 KB
testcase_20 AC 41 ms
52,664 KB
testcase_21 AC 40 ms
52,476 KB
testcase_22 AC 40 ms
53,008 KB
testcase_23 AC 40 ms
53,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

"""

ある要素を左端とする最長部分増加列と、右端とするを求める
→それのmin*2+1

"""

from sys import stdin
import sys

import bisect

def LIS(lis,tmp):

    seq = []

    for c in lis:
        ind = bisect.bisect_left(seq,c)
        tmp.append(ind)

        if ind == len(seq):
            seq.append(c)
        else:
            seq[ind] = c

    return len(seq)

N = int(stdin.readline())
A = list(map(int,stdin.readline().split()))
ans = 0

LI = []
LIS(A,LI)

print (LI,file=sys.stderr)

A.reverse()
RI = []
LIS(A,RI)
RI.reverse()
A.reverse()

print (RI,file=sys.stderr)

for i in range(N):
    ans = max( ans , min(LI[i] , RI[i]) )

for i in range(N):
    A[i] *= -1

LI = []
LIS(A,LI)

print (LI,file=sys.stderr)

A.reverse()
RI = []
LIS(A,RI)
RI.reverse()
A.reverse()

print (RI,file=sys.stderr)

for i in range(N):
    ans = max( ans , min(LI[i] , RI[i]) )

print (ans)
0