結果
| 問題 |
No.397 NO MORE KADOMATSU
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 20:36:51 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 591 bytes |
| コンパイル時間 | 359 ms |
| コンパイル使用メモリ | 82,208 KB |
| 実行使用メモリ | 86,632 KB |
| 最終ジャッジ日時 | 2025-06-12 20:37:22 |
| 合計ジャッジ時間 | 6,782 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | TLE * 1 -- * 17 |
ソースコード
n = int(input())
arr = list(map(int, input().split()))
dummy = input() # read the dummy input
# Sort the array in non-increasing order to avoid kadomatsu sequences
target = sorted(arr, reverse=True)
current = arr.copy()
swaps = []
for i in range(n):
# Find the maximum element's index from i to end
max_idx = i
for j in range(i, n):
if current[j] > current[max_idx]:
max_idx = j
if max_idx != i:
swaps.append((i, max_idx))
current[i], current[max_idx] = current[max_idx], current[i]
print(len(swaps))
for u, v in swaps:
print(u, v)
gew1fw