結果

問題 No.1285 ゴミ捨て
ユーザー tentententen
提出日時 2020-11-16 12:26:12
言語 Java21
(openjdk 21)
結果
AC  
実行時間 640 ms / 2,000 ms
コード長 509 bytes
コンパイル時間 2,075 ms
コンパイル使用メモリ 74,092 KB
実行使用メモリ 50,708 KB
最終ジャッジ日時 2024-05-06 14:38:24
合計ジャッジ時間 11,804 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 115 ms
41,040 KB
testcase_01 AC 116 ms
41,296 KB
testcase_02 AC 101 ms
39,924 KB
testcase_03 AC 121 ms
41,044 KB
testcase_04 AC 120 ms
41,588 KB
testcase_05 AC 127 ms
41,588 KB
testcase_06 AC 127 ms
41,144 KB
testcase_07 AC 583 ms
48,636 KB
testcase_08 AC 196 ms
45,152 KB
testcase_09 AC 456 ms
48,048 KB
testcase_10 AC 598 ms
48,300 KB
testcase_11 AC 566 ms
48,616 KB
testcase_12 AC 520 ms
48,244 KB
testcase_13 AC 500 ms
48,140 KB
testcase_14 AC 538 ms
48,408 KB
testcase_15 AC 525 ms
48,220 KB
testcase_16 AC 312 ms
47,668 KB
testcase_17 AC 323 ms
47,968 KB
testcase_18 AC 319 ms
47,812 KB
testcase_19 AC 437 ms
48,304 KB
testcase_20 AC 302 ms
47,700 KB
testcase_21 AC 342 ms
48,228 KB
testcase_22 AC 577 ms
50,708 KB
testcase_23 AC 640 ms
48,696 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