結果

問題 No.366 ロボットソート
ユーザー AoiroFukurouAoiroFukurou
提出日時 2016-05-07 16:49:01
言語 Java21
(openjdk 21)
結果
AC  
実行時間 211 ms / 2,000 ms
コード長 652 bytes
コンパイル時間 3,225 ms
コンパイル使用メモリ 72,468 KB
実行使用メモリ 56,932 KB
最終ジャッジ日時 2023-08-28 15:15:31
合計ジャッジ時間 8,014 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
55,904 KB
testcase_01 AC 122 ms
55,720 KB
testcase_02 AC 123 ms
55,420 KB
testcase_03 AC 121 ms
55,644 KB
testcase_04 AC 120 ms
55,436 KB
testcase_05 AC 120 ms
55,564 KB
testcase_06 AC 123 ms
55,700 KB
testcase_07 AC 120 ms
55,464 KB
testcase_08 AC 122 ms
55,880 KB
testcase_09 AC 121 ms
53,916 KB
testcase_10 AC 142 ms
55,560 KB
testcase_11 AC 200 ms
56,012 KB
testcase_12 AC 201 ms
56,300 KB
testcase_13 AC 178 ms
55,980 KB
testcase_14 AC 178 ms
55,792 KB
testcase_15 AC 151 ms
55,836 KB
testcase_16 AC 184 ms
55,896 KB
testcase_17 AC 180 ms
55,716 KB
testcase_18 AC 200 ms
56,648 KB
testcase_19 AC 186 ms
56,012 KB
testcase_20 AC 122 ms
55,904 KB
testcase_21 AC 205 ms
56,496 KB
testcase_22 AC 211 ms
56,932 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package yuki_coder;

import java.util.Scanner;

public class No_366 {
public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	int K = sc.nextInt();
	long[] val = new long[N];
	for(int i = 0; i < N; i++){
		val[i] = sc.nextLong();
	}
	int c = 0;
	int MV = N - K - 1;
	flag: for(int i = 0; i <= MV; i++){
				for(int j = 0; j <= MV; j++){
					if(0 > MV){
						break flag;
		}
		if(val[j] > val[j + K]){
			long tmp = val[j];
			val[j] = val[j + K];
			val[j + K] = tmp;
			c++;
					}
			}
	}
	for(int i = 1; i < N; i++){
		if(val[i - 1] > val[i]){
			c = -1;
			break;
		}
	}
	System.out.println(c);
}
}
0