結果

問題 No.366 ロボットソート
ユーザー convexineq
提出日時 2021-01-02 15:53:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 49 ms / 2,000 ms
コード長 255 bytes
コンパイル時間 194 ms
コンパイル使用メモリ 82,120 KB
実行使用メモリ 61,440 KB
最終ジャッジ日時 2024-10-12 04:44:40
合計ジャッジ時間 2,188 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

n,k,*a = map(int,open(0).read().split())
ans = 0
for i in range(k):
    for x in range(i,n,k):
        for y in range(x+k,n,k):
            if a[x] > a[y]:
                ans += 1
    a[i:n:k] = sorted(a[i:n:k])
print(ans if a == list(sorted(a)) else -1)
0