結果

問題 No.2036 Max Middle
ユーザー hir355hir355
提出日時 2022-08-12 21:38:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 115 ms / 2,000 ms
コード長 328 bytes
コンパイル時間 166 ms
コンパイル使用メモリ 81,656 KB
実行使用メモリ 108,084 KB
最終ジャッジ日時 2023-10-24 08:46:04
合計ジャッジ時間 3,022 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,368 KB
testcase_01 AC 38 ms
53,368 KB
testcase_02 AC 37 ms
53,368 KB
testcase_03 AC 38 ms
53,368 KB
testcase_04 AC 37 ms
53,368 KB
testcase_05 AC 40 ms
53,368 KB
testcase_06 AC 38 ms
53,368 KB
testcase_07 AC 38 ms
53,368 KB
testcase_08 AC 81 ms
90,688 KB
testcase_09 AC 106 ms
105,780 KB
testcase_10 AC 113 ms
101,176 KB
testcase_11 AC 98 ms
108,084 KB
testcase_12 AC 97 ms
107,344 KB
testcase_13 AC 115 ms
101,684 KB
testcase_14 AC 49 ms
64,168 KB
testcase_15 AC 47 ms
62,108 KB
testcase_16 AC 111 ms
101,648 KB
testcase_17 AC 91 ms
102,096 KB
testcase_18 AC 86 ms
104,392 KB
testcase_19 AC 97 ms
107,640 KB
testcase_20 AC 104 ms
108,012 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = list(map(int, input().split()))
d = [0] * n
for i in range(1, n - 1):
    if a[i - 1] < a[i]:
        d[i] = d[i - 1] + 1
    else:
        d[i] = d[i - 1]
for i in range(n - 2, 0, -1):
    if a[i + 1] < a[i]:
        d[i] = min(d[i], d[i + 1] + 1)
    else:
        d[i] = min(d[i], d[i + 1])
print(sum(d))
0