結果

問題 No.1285 ゴミ捨て
ユーザー xRS43BofaUEZ5gcxRS43BofaUEZ5gc
提出日時 2021-03-10 09:53:52
言語 Java
(openjdk 23)
結果
AC  
実行時間 607 ms / 2,000 ms
コード長 613 bytes
コンパイル時間 3,094 ms
コンパイル使用メモリ 75,188 KB
実行使用メモリ 59,880 KB
最終ジャッジ日時 2024-11-28 22:01:57
合計ジャッジ時間 12,506 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

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