結果

問題 No.2036 Max Middle
ユーザー ntudantuda
提出日時 2022-08-16 11:56:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 109 ms / 2,000 ms
コード長 268 bytes
コンパイル時間 254 ms
コンパイル使用メモリ 82,704 KB
実行使用メモリ 108,968 KB
最終ジャッジ日時 2024-04-14 06:30:34
合計ジャッジ時間 3,615 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
52,376 KB
testcase_01 AC 37 ms
52,276 KB
testcase_02 AC 37 ms
52,344 KB
testcase_03 AC 36 ms
52,092 KB
testcase_04 AC 37 ms
52,528 KB
testcase_05 AC 37 ms
52,956 KB
testcase_06 AC 37 ms
52,692 KB
testcase_07 AC 37 ms
52,544 KB
testcase_08 AC 75 ms
89,528 KB
testcase_09 AC 99 ms
106,452 KB
testcase_10 AC 107 ms
101,740 KB
testcase_11 AC 97 ms
108,968 KB
testcase_12 AC 92 ms
106,336 KB
testcase_13 AC 109 ms
102,224 KB
testcase_14 AC 47 ms
61,912 KB
testcase_15 AC 44 ms
61,132 KB
testcase_16 AC 107 ms
102,112 KB
testcase_17 AC 86 ms
101,700 KB
testcase_18 AC 86 ms
104,952 KB
testcase_19 AC 91 ms
106,472 KB
testcase_20 AC 98 ms
108,612 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int, input().split()))
B = [0] * N

for i in range(1, N):
    B[i] = B[i - 1] + 1 - 2 * (A[i - 1] > A[i])

xb = (B[0] - B[-1] + N) // 2
c = 0
ans = 0
for i in range(1, N):
    c += 1 - 2 * (i <= xb)
    ans += (B[i] - c)

print(ans // 2)
0