結果

問題 No.365 ジェンガソート
ユーザー marumaru
提出日時 2017-09-27 14:28:22
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 546 bytes
コンパイル時間 3,293 ms
コンパイル使用メモリ 74,692 KB
実行使用メモリ 61,888 KB
最終ジャッジ日時 2024-04-27 14:49:00
合計ジャッジ時間 17,129 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 111 ms
53,976 KB
testcase_01 AC 111 ms
53,160 KB
testcase_02 AC 104 ms
52,956 KB
testcase_03 AC 112 ms
54,048 KB
testcase_04 AC 99 ms
52,452 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 115 ms
53,980 KB
testcase_08 AC 102 ms
52,768 KB
testcase_09 AC 116 ms
54,076 KB
testcase_10 AC 111 ms
53,524 KB
testcase_11 WA -
testcase_12 AC 116 ms
53,688 KB
testcase_13 AC 114 ms
53,180 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 318 ms
58,824 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 443 ms
59,236 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 270 ms
58,728 KB
testcase_35 WA -
testcase_36 AC 477 ms
61,056 KB
testcase_37 AC 464 ms
60,100 KB
testcase_38 AC 530 ms
61,556 KB
testcase_39 AC 463 ms
61,328 KB
testcase_40 AC 532 ms
61,572 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class JengaSort {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		List<Integer> list = new ArrayList<Integer>();
		for (int i = 0; i < N; i++) {
			list.add(sc.nextInt());
		}
		int base = list.get(N - 1);

		int count = 0;
		for (int i = N-1; i > 0; i--) {
			int next = list.get(i - 1);
			if (next == base - 1) {
				base = next;
			} else {
				count++;
			}
		}
		System.out.println(count);

	}
}
0