結果

問題 No.1285 ゴミ捨て
ユーザー xRS43BofaUEZ5gcxRS43BofaUEZ5gc
提出日時 2021-03-10 09:53:52
言語 Java21
(openjdk 21)
結果
AC  
実行時間 633 ms / 2,000 ms
コード長 613 bytes
コンパイル時間 3,170 ms
コンパイル使用メモリ 74,680 KB
実行使用メモリ 50,768 KB
最終ジャッジ日時 2024-05-06 14:45:30
合計ジャッジ時間 12,897 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 116 ms
41,556 KB
testcase_01 AC 114 ms
41,352 KB
testcase_02 AC 121 ms
41,780 KB
testcase_03 AC 107 ms
40,172 KB
testcase_04 AC 110 ms
41,644 KB
testcase_05 AC 124 ms
41,200 KB
testcase_06 AC 125 ms
41,788 KB
testcase_07 AC 633 ms
49,416 KB
testcase_08 AC 195 ms
44,620 KB
testcase_09 AC 394 ms
47,104 KB
testcase_10 AC 603 ms
48,592 KB
testcase_11 AC 547 ms
48,920 KB
testcase_12 AC 427 ms
47,472 KB
testcase_13 AC 521 ms
48,552 KB
testcase_14 AC 624 ms
48,872 KB
testcase_15 AC 522 ms
48,668 KB
testcase_16 AC 310 ms
47,964 KB
testcase_17 AC 326 ms
47,984 KB
testcase_18 AC 337 ms
47,956 KB
testcase_19 AC 435 ms
48,344 KB
testcase_20 AC 297 ms
47,556 KB
testcase_21 AC 360 ms
48,280 KB
testcase_22 AC 606 ms
50,744 KB
testcase_23 AC 633 ms
50,768 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