結果

問題 No.1692 Expectations
ユーザー みーすけみーすけ
提出日時 2021-10-01 21:34:01
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 982 bytes
コンパイル時間 2,909 ms
コンパイル使用メモリ 74,016 KB
実行使用メモリ 75,588 KB
最終ジャッジ日時 2023-09-26 16:35:30
合計ジャッジ時間 14,259 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 152 ms
56,852 KB
testcase_01 AC 153 ms
56,820 KB
testcase_02 AC 190 ms
57,380 KB
testcase_03 AC 212 ms
56,524 KB
testcase_04 AC 172 ms
56,324 KB
testcase_05 AC 222 ms
58,944 KB
testcase_06 AC 221 ms
58,032 KB
testcase_07 AC 156 ms
56,808 KB
testcase_08 AC 217 ms
57,148 KB
testcase_09 AC 171 ms
56,564 KB
testcase_10 AC 747 ms
65,040 KB
testcase_11 AC 712 ms
64,952 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 349 ms
60,628 KB
testcase_15 AC 779 ms
68,956 KB
testcase_16 AC 359 ms
60,508 KB
testcase_17 AC 589 ms
63,320 KB
testcase_18 AC 434 ms
60,568 KB
testcase_19 AC 863 ms
71,076 KB
testcase_20 AC 749 ms
73,228 KB
testcase_21 AC 834 ms
75,588 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }

        int min = 0;
        boolean allSame = true;
        for (int i = 1; i < n; i++) {
            if (a[i] != a[0]) {
                allSame = false;
                break;
            }
        }
        if (allSame) {
            min = 1;
        }
        
        int max = n;
        HashSet<Integer> hs = new HashSet<Integer>();
        for (int i = 0; i < n; i++) {
            if (1 <= a[i] && a[i] <= m) {
                if (hs.contains(a[i])) {
                    max--;
                } else {
                    hs.add(a[i]);
                }
            } else {
                max--;
            }
        }
        System.out.println(max + " " + min);
    }
}
0