結果

問題 No.397 NO MORE KADOMATSU
ユーザー gew1fw
提出日時 2025-06-12 20:40:51
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 620 bytes
コンパイル時間 182 ms
コンパイル使用メモリ 81,932 KB
実行使用メモリ 87,300 KB
最終ジャッジ日時 2025-06-12 20:41:06
合計ジャッジ時間 6,699 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other TLE * 1 -- * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = list(map(int, input().split()))
dummy = int(input())  # This line is just for handling the dummy input

# Create the target array sorted in decreasing order
target = sorted(a, reverse=True)

current = a.copy()
swaps = []

for i in range(n):
    if current[i] == target[i]:
        continue
    # Find the position j where current[j] is target[i]
    for j in range(i, n):
        if current[j] == target[i]:
            break
    # Perform the swap
    current[i], current[j] = current[j], current[i]
    swaps.append((i, j))

# Output the result
print(len(swaps))
for u, v in swaps:
    print(u, v)
0