結果

問題 No.2036 Max Middle
ユーザー FromBooskaFromBooska
提出日時 2023-05-19 17:59:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 154 ms / 2,000 ms
コード長 370 bytes
コンパイル時間 485 ms
コンパイル使用メモリ 87,044 KB
実行使用メモリ 120,348 KB
最終ジャッジ日時 2023-08-22 21:57:09
合計ジャッジ時間 4,276 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
71,200 KB
testcase_01 AC 77 ms
70,996 KB
testcase_02 AC 76 ms
71,176 KB
testcase_03 AC 79 ms
71,076 KB
testcase_04 AC 77 ms
71,284 KB
testcase_05 AC 77 ms
71,180 KB
testcase_06 AC 78 ms
71,284 KB
testcase_07 AC 81 ms
71,200 KB
testcase_08 AC 121 ms
100,280 KB
testcase_09 AC 147 ms
109,316 KB
testcase_10 AC 154 ms
113,020 KB
testcase_11 AC 138 ms
108,040 KB
testcase_12 AC 135 ms
113,192 KB
testcase_13 AC 153 ms
113,368 KB
testcase_14 AC 87 ms
76,316 KB
testcase_15 AC 87 ms
76,096 KB
testcase_16 AC 144 ms
113,228 KB
testcase_17 AC 133 ms
117,904 KB
testcase_18 AC 137 ms
120,348 KB
testcase_19 AC 138 ms
107,348 KB
testcase_20 AC 138 ms
107,804 KB
権限があれば一括ダウンロードができます

ソースコード

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