結果

問題 No.1425 Yet Another Cyclic Shifts Sorting
ユーザー lam6er
提出日時 2025-03-31 17:55:44
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 339 bytes
コンパイル時間 268 ms
コンパイル使用メモリ 82,172 KB
実行使用メモリ 130,420 KB
最終ジャッジ日時 2025-03-31 17:56:59
合計ジャッジ時間 11,513 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27 WA * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = list(map(int, input().split()))

sorted_with_indices = sorted([(val, idx) for idx, val in enumerate(a)], key=lambda x: (x[0], x[1]))
pos = [pair[1] for pair in sorted_with_indices]

required = set()

for i in range(n - 1):
    if pos[i] > pos[i + 1]:
        required.add(max(pos[i], pos[i + 1]))

print(len(required))
0