結果

問題 No.1285 ゴミ捨て
ユーザー tentententen
提出日時 2020-11-16 12:26:12
言語 Java21
(openjdk 21)
結果
AC  
実行時間 565 ms / 2,000 ms
コード長 509 bytes
コンパイル時間 2,330 ms
コンパイル使用メモリ 71,768 KB
実行使用メモリ 63,664 KB
最終ジャッジ日時 2023-08-19 07:23:36
合計ジャッジ時間 10,991 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 114 ms
55,680 KB
testcase_01 AC 111 ms
55,528 KB
testcase_02 AC 117 ms
53,984 KB
testcase_03 AC 117 ms
55,912 KB
testcase_04 AC 111 ms
55,836 KB
testcase_05 AC 117 ms
55,960 KB
testcase_06 AC 121 ms
55,700 KB
testcase_07 AC 565 ms
60,768 KB
testcase_08 AC 195 ms
58,864 KB
testcase_09 AC 406 ms
60,856 KB
testcase_10 AC 551 ms
60,352 KB
testcase_11 AC 503 ms
60,840 KB
testcase_12 AC 465 ms
60,568 KB
testcase_13 AC 451 ms
60,244 KB
testcase_14 AC 514 ms
60,964 KB
testcase_15 AC 470 ms
60,716 KB
testcase_16 AC 308 ms
60,460 KB
testcase_17 AC 300 ms
58,432 KB
testcase_18 AC 313 ms
60,428 KB
testcase_19 AC 422 ms
60,764 KB
testcase_20 AC 295 ms
60,532 KB
testcase_21 AC 347 ms
60,444 KB
testcase_22 AC 537 ms
63,664 KB
testcase_23 AC 561 ms
61,964 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }
        Arrays.sort(arr);
        for (int i = 1; i < n; i++) {
            if (arr[i] == arr[i - 1] + 1) {
                System.out.println(2);
                return;
            }
        }
        System.out.println(1);
    }
}
0