結果

問題 No.366 ロボットソート
ユーザー rocoder
提出日時 2017-08-01 05:25:37
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 567 bytes
コンパイル時間 87 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 17,568 KB
最終ジャッジ日時 2024-10-11 05:43:52
合計ジャッジ時間 4,342 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 16 WA * 1 TLE * 1 -- * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

#robot
N,K=(int(i) for i in input().split())
a=[int(i) for i in input().split()]
b=[0]*N
for i in range(N):
    b[i]=a[i]
b.sort()
i=0
C=0
while i<N and C>=0:
    j=i
    while j<N and C>=0 and b[j]!=a[i]:
        j=i
        while j<N and C>=0 and b[j]!=a[i]:
            j+=K
    #        print(C)
        if j>=N:
            C=-1
        else:
            l=0
            while i+l+K<=j:
                t=a[i+l]
                a[i+l]=a[i+l+K]
                a[i+l+K]=t
                l+=K
                C+=1
   #     print(a)
    i+=1
 #   print(a)
print(C)
0