結果

問題 No.2036 Max Middle
ユーザー FromBooskaFromBooska
提出日時 2023-03-21 19:00:27
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 729 bytes
コンパイル時間 249 ms
コンパイル使用メモリ 81,628 KB
実行使用メモリ 53,468 KB
最終ジャッジ日時 2023-10-18 18:31:05
合計ジャッジ時間 5,981 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
53,468 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 38 ms
53,460 KB
testcase_05 AC 38 ms
53,460 KB
testcase_06 AC 37 ms
53,460 KB
testcase_07 AC 37 ms
53,460 KB
testcase_08 TLE -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

# どの順番に操作をすべきというのはない
# わからないので解説を見ると、毎回不等号リストを更新するようなことが書いてある
# それで間に合うのか? そうならそもそも数字リストの更新でもいいのか?

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

#print(signs)

ans = 0
while True:
    change = False
    for i in range(N-2):
        if signs[i] == '<' and signs[i+1] == '>':
            signs[i] = '>'
            signs[i+1] = '<'
            ans += 1
            change = True
    if change == False:
        break
print(ans)


0