結果

問題 No.366 ロボットソート
ユーザー 👑 H20H20
提出日時 2020-11-19 13:21:36
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 306 bytes
コンパイル時間 414 ms
コンパイル使用メモリ 86,960 KB
実行使用メモリ 76,452 KB
最終ジャッジ日時 2023-09-30 16:16:21
合計ジャッジ時間 3,646 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,192 KB
testcase_01 AC 79 ms
71,316 KB
testcase_02 AC 77 ms
71,224 KB
testcase_03 AC 73 ms
71,344 KB
testcase_04 WA -
testcase_05 AC 74 ms
71,316 KB
testcase_06 AC 76 ms
71,184 KB
testcase_07 WA -
testcase_08 AC 74 ms
71,036 KB
testcase_09 WA -
testcase_10 AC 77 ms
75,728 KB
testcase_11 AC 84 ms
76,028 KB
testcase_12 AC 86 ms
75,976 KB
testcase_13 AC 75 ms
75,572 KB
testcase_14 AC 76 ms
75,604 KB
testcase_15 AC 75 ms
75,892 KB
testcase_16 AC 79 ms
76,132 KB
testcase_17 AC 81 ms
76,416 KB
testcase_18 AC 87 ms
76,156 KB
testcase_19 WA -
testcase_20 AC 72 ms
71,260 KB
testcase_21 AC 83 ms
76,268 KB
testcase_22 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K=map(int, input().split())
A=list(map(int, input().split()))
SA = sorted(A)
cnt = 0
for i in range(N-K-1):
    for j in range(0,N-K-1):
        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