結果

問題 No.2036 Max Middle
ユーザー taiga0629kyoprotaiga0629kyopro
提出日時 2022-08-12 21:48:00
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 310 bytes
コンパイル時間 347 ms
コンパイル使用メモリ 81,724 KB
実行使用メモリ 100,736 KB
最終ジャッジ日時 2023-10-24 09:29:13
合計ジャッジ時間 4,423 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
57,872 KB
testcase_01 AC 37 ms
53,500 KB
testcase_02 AC 41 ms
53,400 KB
testcase_03 AC 38 ms
53,400 KB
testcase_04 AC 37 ms
53,400 KB
testcase_05 AC 39 ms
53,400 KB
testcase_06 AC 38 ms
53,400 KB
testcase_07 AC 39 ms
53,400 KB
testcase_08 TLE -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
a=[10**12]+list(map(int,input().split()))+[10**12]
s=[]
def ok(i):
    return a[i-1]<a[i] and a[i]>a[i+1]
for i in range(1,n+1):
    if ok(i):s.append(i)
ans=0
while s:
    i=s.pop()
    ans+=1
    a[i]=min(a[i-1],a[i+1])-1
    if ok(i-1):s.append(i-1)
    if ok(i+1):s.append(i+1)
print(ans)

0