結果

問題 No.365 ジェンガソート
ユーザー keitamidokeitamido
提出日時 2017-06-10 17:46:40
言語 Java21
(openjdk 21)
結果
AC  
実行時間 567 ms / 2,000 ms
コード長 545 bytes
コンパイル時間 2,023 ms
コンパイル使用メモリ 75,648 KB
実行使用メモリ 68,576 KB
最終ジャッジ日時 2023-10-24 20:33:23
合計ジャッジ時間 15,966 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 114 ms
55,012 KB
testcase_01 AC 110 ms
56,320 KB
testcase_02 AC 124 ms
57,304 KB
testcase_03 AC 113 ms
56,920 KB
testcase_04 AC 125 ms
57,268 KB
testcase_05 AC 120 ms
57,236 KB
testcase_06 AC 119 ms
57,308 KB
testcase_07 AC 120 ms
57,440 KB
testcase_08 AC 124 ms
57,304 KB
testcase_09 AC 109 ms
56,212 KB
testcase_10 AC 121 ms
57,376 KB
testcase_11 AC 110 ms
56,272 KB
testcase_12 AC 122 ms
57,572 KB
testcase_13 AC 124 ms
57,532 KB
testcase_14 AC 110 ms
56,220 KB
testcase_15 AC 131 ms
57,460 KB
testcase_16 AC 468 ms
62,036 KB
testcase_17 AC 509 ms
64,348 KB
testcase_18 AC 242 ms
60,780 KB
testcase_19 AC 567 ms
67,116 KB
testcase_20 AC 361 ms
63,876 KB
testcase_21 AC 302 ms
61,000 KB
testcase_22 AC 449 ms
62,044 KB
testcase_23 AC 387 ms
61,824 KB
testcase_24 AC 439 ms
62,084 KB
testcase_25 AC 288 ms
60,592 KB
testcase_26 AC 420 ms
62,012 KB
testcase_27 AC 501 ms
62,024 KB
testcase_28 AC 408 ms
61,224 KB
testcase_29 AC 487 ms
61,788 KB
testcase_30 AC 451 ms
61,844 KB
testcase_31 AC 336 ms
61,376 KB
testcase_32 AC 333 ms
61,516 KB
testcase_33 AC 468 ms
62,056 KB
testcase_34 AC 275 ms
60,608 KB
testcase_35 AC 463 ms
61,852 KB
testcase_36 AC 544 ms
68,576 KB
testcase_37 AC 474 ms
61,164 KB
testcase_38 AC 461 ms
61,240 KB
testcase_39 AC 546 ms
64,780 KB
testcase_40 AC 487 ms
63,928 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