結果

問題 No.1188 レベルX門松列
ユーザー ntudantuda
提出日時 2023-05-05 13:21:34
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 726 bytes
コンパイル時間 299 ms
コンパイル使用メモリ 87,064 KB
実行使用メモリ 100,996 KB
最終ジャッジ日時 2023-08-14 21:41:42
合計ジャッジ時間 6,219 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 166 ms
98,408 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 171 ms
98,980 KB
testcase_05 AC 67 ms
71,344 KB
testcase_06 AC 152 ms
97,080 KB
testcase_07 AC 183 ms
100,996 KB
testcase_08 AC 181 ms
98,324 KB
testcase_09 AC 67 ms
71,368 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 221 ms
99,376 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 68 ms
71,228 KB
testcase_19 WA -
testcase_20 AC 65 ms
71,432 KB
testcase_21 AC 67 ms
71,264 KB
testcase_22 AC 67 ms
71,436 KB
testcase_23 AC 67 ms
71,400 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):
        ans = max(ans, dp2[0][i] + dp2[1][i] - 1)

print((ans-1)//2)
0