結果

問題 No.2036 Max Middle
ユーザー FromBooskaFromBooska
提出日時 2024-03-18 12:09:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 122 ms / 2,000 ms
コード長 447 bytes
コンパイル時間 377 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 120,440 KB
最終ジャッジ日時 2024-03-18 12:09:07
合計ジャッジ時間 4,187 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,460 KB
testcase_01 AC 37 ms
53,460 KB
testcase_02 AC 37 ms
53,460 KB
testcase_03 AC 37 ms
53,460 KB
testcase_04 AC 37 ms
53,460 KB
testcase_05 AC 37 ms
53,460 KB
testcase_06 AC 38 ms
53,460 KB
testcase_07 AC 37 ms
53,460 KB
testcase_08 AC 83 ms
96,724 KB
testcase_09 AC 107 ms
104,652 KB
testcase_10 AC 122 ms
111,824 KB
testcase_11 AC 107 ms
113,076 KB
testcase_12 AC 108 ms
119,708 KB
testcase_13 AC 119 ms
112,152 KB
testcase_14 AC 45 ms
62,372 KB
testcase_15 AC 46 ms
62,376 KB
testcase_16 AC 117 ms
112,032 KB
testcase_17 AC 97 ms
114,372 KB
testcase_18 AC 102 ms
116,612 KB
testcase_19 AC 106 ms
119,996 KB
testcase_20 AC 107 ms
120,440 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# となりの要素との大小さのみが重要、<>を><に置き換えると考える

N = int(input())
A = list(map(int, input().split()))

inequality = []
for i in range(1, N):
    if A[i-1]<A[i]:
        inequality.append('<')
    else:
        inequality.append('>')

#print(inequality)

ans = 0
count = 0
for i in range(N-1):
    if inequality[i] == '<':
        count += 1
    elif inequality[i] == '>':
        ans += count
print(ans)
0