結果
| 問題 | No.366 ロボットソート |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-09-01 14:22:30 |
| 言語 | Python3 (3.14.3 + numpy 2.4.4 + scipy 1.17.1) |
| 結果 |
AC
|
| 実行時間 | 323 ms / 2,000 ms |
| コード長 | 428 bytes |
| 記録 | |
| コンパイル時間 | 746 ms |
| コンパイル使用メモリ | 20,572 KB |
| 実行使用メモリ | 15,360 KB |
| 最終ジャッジ日時 | 2026-05-06 22:03:46 |
| 合計ジャッジ時間 | 4,900 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 23 |
ソースコード
# -*- coding: utf-8 -*-
N,K = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
for i in range(0, N-K, 1):
for j in range(N-1-K, i-1, -1):
if a[j] > a[j+K]:
temp = a[j]
a[j] = a[j+K]
a[j+K] = temp
ans += 1
is_sorted = True
for i in range(N-1):
if a[i] > a[i+1]:
is_sorted = False
break
print(ans) if is_sorted else print(-1)