結果

問題 No.365 ジェンガソート
ユーザー keitamidokeitamido
提出日時 2017-06-10 16:16:13
言語 Java21
(openjdk 21)
結果
AC  
実行時間 683 ms / 2,000 ms
コード長 545 bytes
コンパイル時間 4,042 ms
コンパイル使用メモリ 82,980 KB
実行使用メモリ 68,360 KB
最終ジャッジ日時 2023-10-24 20:31:26
合計ジャッジ時間 16,971 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
55,788 KB
testcase_01 AC 125 ms
57,248 KB
testcase_02 AC 127 ms
57,284 KB
testcase_03 AC 125 ms
57,236 KB
testcase_04 AC 126 ms
57,036 KB
testcase_05 AC 125 ms
57,252 KB
testcase_06 AC 126 ms
57,328 KB
testcase_07 AC 127 ms
57,300 KB
testcase_08 AC 134 ms
57,216 KB
testcase_09 AC 125 ms
56,892 KB
testcase_10 AC 125 ms
57,196 KB
testcase_11 AC 128 ms
57,688 KB
testcase_12 AC 130 ms
57,476 KB
testcase_13 AC 133 ms
57,460 KB
testcase_14 AC 130 ms
57,304 KB
testcase_15 AC 139 ms
57,420 KB
testcase_16 AC 503 ms
62,068 KB
testcase_17 AC 521 ms
63,328 KB
testcase_18 AC 253 ms
58,832 KB
testcase_19 AC 683 ms
67,076 KB
testcase_20 AC 388 ms
64,164 KB
testcase_21 AC 318 ms
61,800 KB
testcase_22 AC 485 ms
60,048 KB
testcase_23 AC 403 ms
61,784 KB
testcase_24 AC 468 ms
61,828 KB
testcase_25 AC 335 ms
61,524 KB
testcase_26 AC 449 ms
62,036 KB
testcase_27 AC 502 ms
61,880 KB
testcase_28 AC 395 ms
60,692 KB
testcase_29 AC 519 ms
61,984 KB
testcase_30 AC 457 ms
61,860 KB
testcase_31 AC 355 ms
61,788 KB
testcase_32 AC 321 ms
61,568 KB
testcase_33 AC 540 ms
62,016 KB
testcase_34 AC 297 ms
59,804 KB
testcase_35 AC 494 ms
61,896 KB
testcase_36 AC 578 ms
68,360 KB
testcase_37 AC 525 ms
62,064 KB
testcase_38 AC 497 ms
61,824 KB
testcase_39 AC 586 ms
64,784 KB
testcase_40 AC 553 ms
64,616 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

class JengaSortFix3 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int length = sc.nextInt();
		int cnt = length - 1;
		HashSet<Integer> nset = new HashSet<Integer>();
		int maxInSet = sc.nextInt();
		nset.add(maxInSet);
		for (int i = 0; i < length - 1; i++) {
			int next = sc.nextInt();
			if (next > maxInSet) {
				maxInSet = next;
				if (nset.contains(next - 1)) {
					cnt--;
				} else {
					cnt = length - 1;
				}
			nset.add(next);
			}
		}
		System.out.println(cnt);
	}
}
0