結果

問題 No.366 ロボットソート
ユーザー rocoderrocoder
提出日時 2017-08-01 05:25:37
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 567 bytes
コンパイル時間 131 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 16,256 KB
最終ジャッジ日時 2024-04-19 13:20:42
合計ジャッジ時間 4,220 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
16,256 KB
testcase_01 AC 25 ms
10,880 KB
testcase_02 AC 25 ms
10,752 KB
testcase_03 AC 28 ms
10,752 KB
testcase_04 AC 26 ms
10,880 KB
testcase_05 AC 27 ms
10,752 KB
testcase_06 AC 25 ms
10,752 KB
testcase_07 AC 24 ms
10,880 KB
testcase_08 AC 25 ms
10,752 KB
testcase_09 AC 25 ms
10,752 KB
testcase_10 AC 25 ms
10,752 KB
testcase_11 AC 26 ms
10,880 KB
testcase_12 AC 27 ms
10,880 KB
testcase_13 AC 28 ms
10,752 KB
testcase_14 AC 26 ms
10,880 KB
testcase_15 AC 24 ms
10,752 KB
testcase_16 WA -
testcase_17 TLE -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
権限があれば一括ダウンロードができます

ソースコード

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