結果

問題 No.366 ロボットソート
コンテスト
ユーザー roiti46
提出日時 2016-04-29 22:59:28
言語 PyPy2
(7.3.15)
結果
RE  
実行時間 -
コード長 415 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 146 ms
コンパイル使用メモリ 77,860 KB
最終ジャッジ日時 2025-12-03 20:35:31
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 22 RE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

# -*- 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