結果

問題 No.366 ロボットソート
ユーザー roiti46roiti46
提出日時 2016-04-29 22:59:28
言語 Python2
(2.7.18)
結果
RE  
実行時間 -
コード長 415 bytes
コンパイル時間 104 ms
コンパイル使用メモリ 6,944 KB
実行使用メモリ 15,264 KB
最終ジャッジ日時 2024-04-15 05:47:04
合計ジャッジ時間 7,693 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
15,264 KB
testcase_01 AC 25 ms
8,192 KB
testcase_02 AC 24 ms
8,192 KB
testcase_03 RE -
testcase_04 AC 25 ms
8,320 KB
testcase_05 AC 24 ms
8,192 KB
testcase_06 AC 24 ms
8,192 KB
testcase_07 AC 23 ms
8,192 KB
testcase_08 AC 25 ms
8,192 KB
testcase_09 AC 29 ms
8,192 KB
testcase_10 AC 26 ms
8,192 KB
testcase_11 AC 190 ms
8,192 KB
testcase_12 AC 747 ms
8,192 KB
testcase_13 AC 26 ms
8,192 KB
testcase_14 AC 25 ms
8,192 KB
testcase_15 AC 25 ms
8,064 KB
testcase_16 AC 61 ms
8,192 KB
testcase_17 AC 176 ms
8,192 KB
testcase_18 AC 1,529 ms
8,192 KB
testcase_19 AC 702 ms
8,192 KB
testcase_20 AC 24 ms
8,192 KB
testcase_21 AC 25 ms
8,064 KB
testcase_22 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

# -*- coding: utf-8 -*-
import sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll

N, K = map(int, raw_input().split())
a = map(int, raw_input().split())

i = ans = 0
while i < N - K:
    if a[i] > a[i + K]:
        a[i], a[i + K] = a[i + K], a[i]
        ans += 1
        i = 0
    else:
        i += 1
if min(a[i + 1] - a[i] for i in xrange(N - 1)) >= 1:
    print ans
else:
    print -1
0