結果
| 問題 |
No.366 ロボットソート
|
| コンテスト | |
| ユーザー |
tookunn_1213
|
| 提出日時 | 2016-04-29 23:36:38 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 80 ms / 2,000 ms |
| コード長 | 564 bytes |
| コンパイル時間 | 254 ms |
| コンパイル使用メモリ | 81,920 KB |
| 実行使用メモリ | 61,696 KB |
| 最終ジャッジ日時 | 2024-12-29 17:44:05 |
| 合計ジャッジ時間 | 2,355 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 23 |
ソースコード
def check(a,b,N): for i in range(N): if a[i] not in b[i % K]: return False return True N,K = map(int,input().split()) a = [int(i) for i in input().split()] b = [set([]) for i in range(K)] c = sorted([i for i in a]) for i in range(N): b[i % K].add(c[i]) if not check(a,b,N): print(-1) else: cnt = 0 while True: flag = True for i in range(N - 1): if a[i] > a[i + 1]: flag = False if flag: break for i in range(N): j = i + K while j < N: if a[j - K] > a[j]: a[j],a[j - K] = a[j - K],a[j] cnt+=1 j += K print (cnt)
tookunn_1213