結果

問題 No.1188 レベルX門松列
ユーザー titiatitia
提出日時 2020-08-22 15:08:00
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 585 ms / 2,000 ms
コード長 907 bytes
コンパイル時間 284 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 42,368 KB
最終ジャッジ日時 2024-04-23 09:30:56
合計ジャッジ時間 7,665 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 486 ms
20,740 KB
testcase_01 AC 471 ms
30,532 KB
testcase_02 AC 410 ms
28,396 KB
testcase_03 AC 564 ms
34,404 KB
testcase_04 AC 520 ms
42,368 KB
testcase_05 AC 29 ms
10,880 KB
testcase_06 AC 505 ms
18,500 KB
testcase_07 AC 548 ms
36,720 KB
testcase_08 AC 504 ms
36,704 KB
testcase_09 AC 28 ms
10,752 KB
testcase_10 AC 26 ms
10,880 KB
testcase_11 AC 64 ms
12,580 KB
testcase_12 AC 65 ms
12,368 KB
testcase_13 AC 67 ms
12,684 KB
testcase_14 AC 332 ms
26,028 KB
testcase_15 AC 585 ms
39,480 KB
testcase_16 AC 31 ms
11,008 KB
testcase_17 AC 438 ms
30,920 KB
testcase_18 AC 26 ms
10,880 KB
testcase_19 AC 405 ms
29,852 KB
testcase_20 AC 28 ms
10,752 KB
testcase_21 AC 28 ms
10,880 KB
testcase_22 AC 27 ms
10,880 KB
testcase_23 AC 27 ms
10,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N=int(input())
A=list(map(int,input().split()))

compression_dict={a: ind for ind, a in enumerate(sorted(set(A)))}
A=[compression_dict[a] for a in A]

import bisect

DP=[float("inf")]*N # DP[i]で、長さiのLISの最終要素の最小値.
ANS1=[]

for a in A:
    pos=bisect.bisect_left(DP,a)
    DP[pos]=a

    ANS1.append(pos)

B=A[::-1]
DP=[float("inf")]*N
ANS2=[]

for a in B:
    pos=bisect.bisect_left(DP,a)
    DP[pos]=a

    ANS2.append(pos)

ANS2=ANS2[::-1]
MAX=max(A)
C=[MAX-a for a in A]

DP=[float("inf")]*N
ANS3=[]

for a in C:
    pos=bisect.bisect_left(DP,a)
    DP[pos]=a

    ANS3.append(pos)

D=C[::-1]
DP=[float("inf")]*N
ANS4=[]

for a in D:
    pos=bisect.bisect_left(DP,a)
    DP[pos]=a

    ANS4.append(pos)

ANS4=ANS4[::-1]

ANS=0
for i in range(N):
    ANS=max(ANS,min(ANS1[i],ANS2[i]))
    ANS=max(ANS,min(ANS3[i],ANS4[i]))

print(ANS)




0