結果

問題 No.1425 Yet Another Cyclic Shifts Sorting
ユーザー gew1fw
提出日時 2025-06-12 14:12:14
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 530 bytes
コンパイル時間 199 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 118,060 KB
最終ジャッジ日時 2025-06-12 14:12:49
合計ジャッジ時間 9,439 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26 WA * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = list(map(int, input().split()))
sorted_pairs = sorted((val, idx) for idx, val in enumerate(a))
original_pos = [pair[1] for pair in sorted_pairs]

required_tools = set()
i = 0
while i < n:
    if original_pos[i] <= i:
        i += 1
        continue
    # Start of a new segment
    max_m = original_pos[i]
    start = i
    while i < n and original_pos[i] > i:
        if original_pos[i] > max_m:
            max_m = original_pos[i]
        i += 1
    required_tools.add(max_m + 1)

print(len(required_tools))
0