結果

問題 No.2036 Max Middle
ユーザー ikomaikoma
提出日時 2022-08-12 22:19:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 109 ms / 2,000 ms
コード長 434 bytes
コンパイル時間 165 ms
コンパイル使用メモリ 81,724 KB
実行使用メモリ 115,188 KB
最終ジャッジ日時 2023-10-24 10:30:34
合計ジャッジ時間 2,783 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,484 KB
testcase_01 AC 37 ms
53,484 KB
testcase_02 AC 37 ms
53,484 KB
testcase_03 AC 37 ms
53,484 KB
testcase_04 AC 38 ms
53,484 KB
testcase_05 AC 37 ms
53,484 KB
testcase_06 AC 36 ms
53,484 KB
testcase_07 AC 37 ms
53,484 KB
testcase_08 AC 74 ms
91,400 KB
testcase_09 AC 96 ms
102,408 KB
testcase_10 AC 109 ms
104,464 KB
testcase_11 AC 95 ms
111,472 KB
testcase_12 AC 88 ms
109,184 KB
testcase_13 AC 108 ms
104,840 KB
testcase_14 AC 45 ms
62,288 KB
testcase_15 AC 44 ms
60,092 KB
testcase_16 AC 103 ms
104,568 KB
testcase_17 AC 86 ms
106,348 KB
testcase_18 AC 90 ms
115,188 KB
testcase_19 AC 88 ms
109,444 KB
testcase_20 AC 93 ms
105,088 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
N=int(input())
A=list(map(int,input().split()))
A.append(A[-1])
A.append(A[-1])
ans = 0

a0 = A[0]
flg=0
lst = []
cnt = 0
for i in range(1,N+1):
    a = A[i]
    if a0 < a > A[i+1]:
        flg=1
    if a==a0:
        if flg:
            for j in lst:
                ans += cnt-j
        flg=0
        cnt=0
    elif a0 < a:
        lst.append(cnt)
    else:
        cnt+=1
    a0 = a
print(ans)
0