結果

問題 No.366 ロボットソート
ユーザー HachimoriHachimori
提出日時 2016-04-29 22:52:42
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 781 bytes
コンパイル時間 53 ms
コンパイル使用メモリ 7,040 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-15 05:43:54
合計ジャッジ時間 1,133 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 11 ms
6,940 KB
testcase_02 AC 11 ms
6,940 KB
testcase_03 AC 11 ms
6,944 KB
testcase_04 WA -
testcase_05 AC 12 ms
6,944 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 11 ms
6,944 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 10 ms
6,944 KB
testcase_21 WA -
testcase_22 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python
#coding:utf8


def read():
    N, K = map(int, raw_input().split())
    vList = map(int, raw_input().split())
    return K, vList


def calcCost(subList):
    ret = 0
    for i in range(len(subList)):
        for j in range(len(subList) - i - 1):
            if subList[j] > subList[j + 1]:
                subList[j], subList[j + 1] = subList[j + 1], subList[j]
                ret += 1
    return ret


def work((K, vList)):
    
    for i in range(K):
        if i + K >= len(vList) and i + 1 < len(vList) and vList[i] > vList[i + 1]:
            print -1
            return

    ans = 0
    for i in range(min(K, len(vList) - K)):
        print vList[i::K]
        ans += calcCost(vList[i::K])

    print ans


if __name__ == "__main__":
    work(read())
0