結果

問題 No.1188 レベルX門松列
ユーザー ntudantuda
提出日時 2023-05-05 13:30:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 224 ms / 2,000 ms
コード長 745 bytes
コンパイル時間 380 ms
コンパイル使用メモリ 86,928 KB
実行使用メモリ 100,680 KB
最終ジャッジ日時 2023-08-14 21:48:41
合計ジャッジ時間 4,995 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 172 ms
98,048 KB
testcase_01 AC 201 ms
95,956 KB
testcase_02 AC 198 ms
93,276 KB
testcase_03 AC 224 ms
98,952 KB
testcase_04 AC 173 ms
98,548 KB
testcase_05 AC 69 ms
71,148 KB
testcase_06 AC 151 ms
96,716 KB
testcase_07 AC 183 ms
100,680 KB
testcase_08 AC 185 ms
97,788 KB
testcase_09 AC 70 ms
71,348 KB
testcase_10 AC 71 ms
71,148 KB
testcase_11 AC 120 ms
78,216 KB
testcase_12 AC 119 ms
77,984 KB
testcase_13 AC 121 ms
77,984 KB
testcase_14 AC 178 ms
89,260 KB
testcase_15 AC 223 ms
99,304 KB
testcase_16 AC 97 ms
76,760 KB
testcase_17 AC 197 ms
93,752 KB
testcase_18 AC 70 ms
71,300 KB
testcase_19 AC 193 ms
93,532 KB
testcase_20 AC 70 ms
71,172 KB
testcase_21 AC 72 ms
71,060 KB
testcase_22 AC 69 ms
71,304 KB
testcase_23 AC 68 ms
71,336 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import bisect_left

N = int(input())
A1 = list(map(int, input().split()))
maxa = max(A1)
A2 = []
for i in range(N):
    A2.append(maxa - A1[i])
A = [A1,A2]
ans = 0
for j in range(2):
    dp2 = [[0] * N for _ in range(2)]
    for k in range(2):
        if k == 0:
            dp = [A[j][0]]
        else:
            dp = [A[j][-1]]
        now = 1
        for i in range(N):
            if k == 1:
                i = N - i - 1
            a = A[j][i]
            if a > dp[-1]:
                dp.append(a)
                now += 1
            else:
                dp[bisect_left(dp, a)] = a
            dp2[k][i] = now
    for i in range(N):
        if dp2[0][i] == dp2[1][i]:
            ans = max(ans, dp2[0][i] - 1)
print(ans)
0