結果

問題 No.397 NO MORE KADOMATSU
ユーザー maspymaspy
提出日時 2020-02-02 12:35:46
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 144 ms / 2,000 ms
コード長 449 bytes
コンパイル時間 124 ms
コンパイル使用メモリ 10,808 KB
実行使用メモリ 45,896 KB
平均クエリ数 52.17
最終ジャッジ日時 2023-09-24 02:25:58
合計ジャッジ時間 4,189 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 144 ms
45,488 KB
testcase_01 AC 135 ms
45,220 KB
testcase_02 AC 136 ms
45,116 KB
testcase_03 AC 134 ms
45,376 KB
testcase_04 AC 132 ms
45,360 KB
testcase_05 AC 133 ms
45,044 KB
testcase_06 AC 139 ms
45,452 KB
testcase_07 AC 132 ms
45,540 KB
testcase_08 AC 134 ms
45,152 KB
testcase_09 AC 137 ms
45,728 KB
testcase_10 AC 136 ms
45,896 KB
testcase_11 AC 133 ms
45,516 KB
testcase_12 AC 135 ms
45,260 KB
testcase_13 AC 135 ms
45,664 KB
testcase_14 AC 132 ms
45,624 KB
testcase_15 AC 133 ms
45,856 KB
testcase_16 AC 135 ms
45,136 KB
testcase_17 AC 133 ms
45,832 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
readline = sys.stdin.buffer.readline

import numpy as np

N = int(readline())
A = np.fromstring(readline(), np.int64, sep=' ')

answer = []

def swap_sort(A,ind):
    if ind == 1:
        return
    n = A[:ind].argmax()
    if n == ind-1:
        swap_sort(A,ind-1)
        return
    answer.append((n,ind-1))
    A[n], A[ind-1] = A[ind-1], A[n]
    swap_sort(A,ind-1)

swap_sort(A,N)

print(len(answer))
for i,j in answer:
    print(i,j)
0