結果
| 問題 | 
                            No.1692 Expectations
                             | 
                    
| コンテスト | |
| ユーザー | 
                             みーすけ
                         | 
                    
| 提出日時 | 2021-10-01 21:34:01 | 
| 言語 | Java  (openjdk 23)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 982 bytes | 
| コンパイル時間 | 2,231 ms | 
| コンパイル使用メモリ | 76,904 KB | 
| 実行使用メモリ | 68,356 KB | 
| 最終ジャッジ日時 | 2024-07-19 10:40:25 | 
| 合計ジャッジ時間 | 12,272 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 18 WA * 2 | 
ソースコード
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);
    }
}
            
            
            
        
            
みーすけ