結果

問題 No.366 ロボットソート
ユーザー 👑 H20H20
提出日時 2020-11-19 13:22:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 90 ms / 2,000 ms
コード長 302 bytes
コンパイル時間 468 ms
コンパイル使用メモリ 86,912 KB
実行使用メモリ 76,484 KB
最終ジャッジ日時 2023-09-30 16:16:25
合計ジャッジ時間 3,465 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,488 KB
testcase_01 AC 75 ms
71,404 KB
testcase_02 AC 75 ms
71,300 KB
testcase_03 AC 76 ms
71,468 KB
testcase_04 AC 88 ms
71,540 KB
testcase_05 AC 77 ms
71,500 KB
testcase_06 AC 79 ms
71,456 KB
testcase_07 AC 77 ms
71,400 KB
testcase_08 AC 76 ms
71,396 KB
testcase_09 AC 75 ms
71,628 KB
testcase_10 AC 79 ms
75,752 KB
testcase_11 AC 85 ms
76,452 KB
testcase_12 AC 90 ms
76,164 KB
testcase_13 AC 79 ms
75,728 KB
testcase_14 AC 78 ms
75,784 KB
testcase_15 AC 77 ms
75,712 KB
testcase_16 AC 81 ms
76,264 KB
testcase_17 AC 84 ms
76,456 KB
testcase_18 AC 89 ms
76,484 KB
testcase_19 AC 84 ms
76,168 KB
testcase_20 AC 76 ms
71,424 KB
testcase_21 AC 83 ms
76,304 KB
testcase_22 AC 87 ms
76,116 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K=map(int, input().split())
A=list(map(int, input().split()))
SA = sorted(A)
cnt = 0
for i in range(N-K):
    for j in range(0,N-K):
        if A[j] > A[j+K]:
            A[j],A[j+K]=A[j+K],A[j]
            cnt+=1
for i in range(N):
    if SA[i]!=A[i]:
        print(-1)
        exit()
print(cnt)



0