結果

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

ソースコード

diff #

import bisect

n = int(input())
a = list(map(int, input().split()))
elements = sorted([(a[i], i + 1) for i in range(n)], key=lambda x: (x[0], x[1]))
pos = [e[1] for e in elements]

d = []
for x in pos:
    idx = bisect.bisect_left(d, x)
    if idx == len(d):
        d.append(x)
    else:
        d[idx] = x
print(n - len(d))
0