結果

問題 No.365 ジェンガソート
ユーザー shinwisteriashinwisteria
提出日時 2017-04-01 12:27:04
言語 Java21
(openjdk 21)
結果
AC  
実行時間 802 ms / 2,000 ms
コード長 544 bytes
コンパイル時間 3,843 ms
コンパイル使用メモリ 72,812 KB
実行使用メモリ 69,324 KB
最終ジャッジ日時 2023-09-22 01:59:35
合計ジャッジ時間 22,878 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,872 KB
testcase_01 AC 127 ms
55,744 KB
testcase_02 AC 123 ms
55,904 KB
testcase_03 AC 126 ms
56,044 KB
testcase_04 AC 124 ms
55,864 KB
testcase_05 AC 123 ms
56,132 KB
testcase_06 AC 125 ms
54,456 KB
testcase_07 AC 123 ms
56,020 KB
testcase_08 AC 125 ms
56,008 KB
testcase_09 AC 126 ms
55,836 KB
testcase_10 AC 127 ms
55,876 KB
testcase_11 AC 127 ms
55,756 KB
testcase_12 AC 125 ms
55,812 KB
testcase_13 AC 130 ms
56,204 KB
testcase_14 AC 124 ms
55,760 KB
testcase_15 AC 133 ms
56,028 KB
testcase_16 AC 665 ms
65,132 KB
testcase_17 AC 691 ms
67,276 KB
testcase_18 AC 285 ms
59,528 KB
testcase_19 AC 726 ms
65,104 KB
testcase_20 AC 419 ms
60,860 KB
testcase_21 AC 386 ms
60,420 KB
testcase_22 AC 656 ms
66,052 KB
testcase_23 AC 495 ms
62,228 KB
testcase_24 AC 662 ms
63,124 KB
testcase_25 AC 367 ms
60,368 KB
testcase_26 AC 601 ms
62,116 KB
testcase_27 AC 772 ms
69,276 KB
testcase_28 AC 576 ms
62,460 KB
testcase_29 AC 739 ms
67,320 KB
testcase_30 AC 634 ms
62,468 KB
testcase_31 AC 404 ms
60,484 KB
testcase_32 AC 395 ms
60,304 KB
testcase_33 AC 797 ms
68,732 KB
testcase_34 AC 341 ms
62,544 KB
testcase_35 AC 659 ms
65,364 KB
testcase_36 AC 642 ms
66,556 KB
testcase_37 AC 626 ms
65,628 KB
testcase_38 AC 802 ms
69,324 KB
testcase_39 AC 681 ms
65,464 KB
testcase_40 AC 644 ms
66,420 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
import java.util.TreeSet;
public class Jengasort {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner s = new Scanner(System.in);
		int N = s.nextInt(),count = N-1;
		TreeSet<Integer> list = new TreeSet<>();
		list.add(s.nextInt());
		for(int i = 1;i < N;i++){
			int k = s.nextInt();
			if(list.last() < k){
				if(list.contains(k-1)){
					count--;
				}else{
					count = N-1;
				}
			}
			list.add(k);
		}
		s.close();
		System.out.println(count);

	}

}
0