結果

問題 No.397 NO MORE KADOMATSU
ユーザー はむ吉🐹はむ吉🐹
提出日時 2016-07-15 22:55:47
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 62 ms / 2,000 ms
コード長 529 bytes
コンパイル時間 163 ms
コンパイル使用メモリ 10,804 KB
実行使用メモリ 24,664 KB
平均クエリ数 936.56
最終ジャッジ日時 2023-09-24 00:15:11
合計ジャッジ時間 2,217 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
24,408 KB
testcase_01 AC 38 ms
23,400 KB
testcase_02 AC 37 ms
23,552 KB
testcase_03 AC 40 ms
23,488 KB
testcase_04 AC 37 ms
23,464 KB
testcase_05 AC 40 ms
23,456 KB
testcase_06 AC 43 ms
24,304 KB
testcase_07 AC 43 ms
24,128 KB
testcase_08 AC 38 ms
23,592 KB
testcase_09 AC 37 ms
24,036 KB
testcase_10 AC 62 ms
24,388 KB
testcase_11 AC 38 ms
23,568 KB
testcase_12 AC 47 ms
24,608 KB
testcase_13 AC 50 ms
24,664 KB
testcase_14 AC 52 ms
24,456 KB
testcase_15 AC 51 ms
24,280 KB
testcase_16 AC 38 ms
23,652 KB
testcase_17 AC 39 ms
24,292 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3

import sys


def main():
    n = int(input())
    xs = list(map(int, input().split()))
    m = 0
    ops = []
    flag = True
    while flag:
        flag = False
        for j in range(1, n)[::-1]:
            if xs[j] < xs[j - 1]:
                xs[j], xs[j - 1] = xs[j - 1], xs[j]
                ops.append((j, j - 1))
                m += 1
                flag = True
    print(m)
    for op in ops:
        print(*op)
    sys.stdout.flush()
    _ = input()


if __name__ == '__main__':
    main()
0