結果

問題 No.182 新規性の虜
ユーザー dazy
提出日時 2017-02-23 14:34:39
言語 Java
(openjdk 23)
結果
AC  
実行時間 754 ms / 5,000 ms
コード長 599 bytes
コンパイル時間 6,009 ms
コンパイル使用メモリ 74,912 KB
実行使用メモリ 53,548 KB
最終ジャッジ日時 2024-12-27 15:39:55
合計ジャッジ時間 16,023 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Run {
    public static void main (String arg[]) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int ans = N;
        int A;
        HashMap<Integer, Integer> M = new HashMap<>();
        for (int i = 0; i < N; i++) {
            A = scan.nextInt();
            if (!M.containsKey(A)) M.put(A, 1);
            else {
                if (M.get(A)==1) {
                    ans-=2;
                    M.put(A, 2);
                }
                else ans--;
            }
        }
        System.out.println(ans);
    }
}
0