結果

問題 No.1285 ゴミ捨て
ユーザー xRS43BofaUEZ5gcxRS43BofaUEZ5gc
提出日時 2021-03-10 09:53:52
言語 Java21
(openjdk 21)
結果
AC  
実行時間 542 ms / 2,000 ms
コード長 613 bytes
コンパイル時間 3,983 ms
コンパイル使用メモリ 73,192 KB
実行使用メモリ 62,040 KB
最終ジャッジ日時 2023-08-19 07:30:47
合計ジャッジ時間 12,615 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 104 ms
55,936 KB
testcase_01 AC 109 ms
55,300 KB
testcase_02 AC 116 ms
55,896 KB
testcase_03 AC 115 ms
55,776 KB
testcase_04 AC 108 ms
55,748 KB
testcase_05 AC 114 ms
56,072 KB
testcase_06 AC 111 ms
56,076 KB
testcase_07 AC 527 ms
61,192 KB
testcase_08 AC 201 ms
58,572 KB
testcase_09 AC 388 ms
60,360 KB
testcase_10 AC 506 ms
60,404 KB
testcase_11 AC 478 ms
60,804 KB
testcase_12 AC 449 ms
60,432 KB
testcase_13 AC 413 ms
60,716 KB
testcase_14 AC 505 ms
60,536 KB
testcase_15 AC 442 ms
61,052 KB
testcase_16 AC 272 ms
60,104 KB
testcase_17 AC 290 ms
59,728 KB
testcase_18 AC 284 ms
60,376 KB
testcase_19 AC 383 ms
60,448 KB
testcase_20 AC 285 ms
60,036 KB
testcase_21 AC 332 ms
60,316 KB
testcase_22 AC 526 ms
62,040 KB
testcase_23 AC 542 ms
61,332 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;

public class HelloWorld {

	    public static void main(String[] args) throws Exception {

	    	Scanner sc = new Scanner(System.in);
	    	int n = sc.nextInt();
	    	int[] ai = new int[n];
	    	for (int i = 0; i < n; i ++) {
	    		ai[i] = sc.nextInt();
	    	}
	    	sc.close();

	    	Arrays.sort(ai);
	    	int count = 1;
	    	int mod = ai[0] % 2;
	    	for (int i = 1; i < n; i ++ ) {

	    		if (ai[i] % 2 != mod && ai[i] - 1 <= ai[i - 1]) {
	    			count = 2;
	    		}
	    		mod = ai[i] % 2;
	    	}

	    	System.out.println(count);
	    	}

	    }
0