結果
問題 | No.2210 equence Squence Seuence |
ユーザー |
![]() |
提出日時 | 2025-03-26 15:46:33 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 525 ms / 2,000 ms |
コード長 | 1,135 bytes |
コンパイル時間 | 301 ms |
コンパイル使用メモリ | 82,284 KB |
実行使用メモリ | 117,744 KB |
最終ジャッジ日時 | 2025-03-26 15:47:20 |
合計ジャッジ時間 | 7,108 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 |
ソースコード
import sysfrom functools import cmp_to_keydef main():N, K = map(int, sys.stdin.readline().split())A = list(map(int, sys.stdin.readline().split()))next_diff = [-1] * Nnext_diff[-1] = -1 # since there's no next element after lastfor i in range(N-2, -1, -1):if A[i] != A[i+1]:next_diff[i] = ielse:next_diff[i] = next_diff[i+1]def compare(i, j):if i == j:return 0if i > j:return -compare(j, i)# Now i < jm = next_diff[i]if m != -1 and m < j:a = A[m+1]b = A[m]if a < b:return -1elif a > b:return 1else:return 0else:# All elements from i to j-1 are same, compare indicesreturn -1 # since i < j, so X_i comes before X_jindices = list(range(N))indices.sort(key=cmp_to_key(compare))selected = indices[K-1]result = A[:selected] + A[selected+1:]print(' '.join(map(str, result)))if __name__ == "__main__":main()