結果

問題 No.2036 Max Middle
ユーザー FromBooska
提出日時 2023-05-19 17:59:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 112 ms / 2,000 ms
コード長 370 bytes
コンパイル時間 268 ms
コンパイル使用メモリ 82,288 KB
実行使用メモリ 120,544 KB
最終ジャッジ日時 2024-12-18 00:22:09
合計ジャッジ時間 2,941 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

# 公式解説の方法をもう一度やる

N = int(input())
A = list(map(int, input().split()))
signs = []
for i in range(1, N):
    if A[i] > A[i-1]:
        signs.append(+1)
    else:
        signs.append(-1)

count = 0
subcount = 0
for i in range(N-1):
    if signs[i] == 1:
        subcount += 1
    elif signs[i] == -1:
        count += subcount
print(count)



0