結果

問題 No.182 新規性の虜
ユーザー tsunabittsunabit
提出日時 2018-05-09 18:34:03
言語 Java19
(openjdk 21)
結果
AC  
実行時間 503 ms / 5,000 ms
コード長 1,840 bytes
コンパイル時間 3,779 ms
コンパイル使用メモリ 80,736 KB
実行使用メモリ 69,976 KB
最終ジャッジ日時 2023-09-10 11:28:23
合計ジャッジ時間 13,974 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
54,368 KB
testcase_01 AC 124 ms
55,508 KB
testcase_02 AC 124 ms
55,976 KB
testcase_03 AC 124 ms
55,976 KB
testcase_04 AC 125 ms
55,576 KB
testcase_05 AC 126 ms
55,948 KB
testcase_06 AC 124 ms
56,124 KB
testcase_07 AC 125 ms
56,072 KB
testcase_08 AC 415 ms
66,320 KB
testcase_09 AC 503 ms
69,152 KB
testcase_10 AC 495 ms
69,976 KB
testcase_11 AC 476 ms
67,520 KB
testcase_12 AC 312 ms
60,364 KB
testcase_13 AC 123 ms
55,688 KB
testcase_14 AC 124 ms
55,852 KB
testcase_15 AC 123 ms
55,872 KB
testcase_16 AC 122 ms
55,568 KB
testcase_17 AC 126 ms
55,524 KB
testcase_18 AC 402 ms
66,584 KB
testcase_19 AC 338 ms
62,336 KB
testcase_20 AC 301 ms
61,756 KB
testcase_21 AC 396 ms
67,916 KB
testcase_22 AC 303 ms
59,952 KB
testcase_23 AC 123 ms
55,832 KB
testcase_24 AC 472 ms
69,172 KB
testcase_25 AC 342 ms
64,568 KB
testcase_26 AC 238 ms
59,692 KB
testcase_27 AC 123 ms
55,936 KB
evil01.txt AC 512 ms
73,124 KB
evil02.txt AC 508 ms
73,412 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
import java.util.stream.Stream;
import java.util.Arrays;
import java.util.HashMap;

// ***問題文***
// kamipeipaa君は新しいものが大好きです。
// kamipeipaa君はある日N個の整数A1,A2,A3,....,ANを見つけました。
// 整数Aiに対して,Ai=Ajとなるjがi以外に存在しなければ,Aiは新規性があるのではないかとkamipeipaa君は考えました。
// 上記の条件を満たす整数がいくつあるかkamipeipaa君に教えてあげてください。
// ***入力***
// N
// A1 A2 ... AN
// 1行目にkamipeipaa君が見つけた数の総数N(1≤N≤105)
// が与えられる。
// 2行目にkamipeipaa君が見つけた数A1,A2,....,AN(1≤Ai≤109)が空白区切りで与えられる。
// ***出力***
// 条件を満たすようなものの数を1行に出力せよ。改行を忘れないこと。

public class No182 {
    public static void main(String[] args) {
        // 標準入力から読み込む際に、Scannerオブジェクトを使う。
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.nextLine());
        // int[] a = Stream.of(sc.nextLine().split(" " , 0)).mapToInt(Integer::parseInt).toArray();
        int[] a = Stream.of(sc.nextLine().split(" " , 0)).mapToInt(Integer::parseInt).toArray();
        HashMap<Integer, Integer> ha = new HashMap<Integer, Integer>();
        for(int i = 0; i < a.length; i++) {
            if(ha.containsKey(a[i])) {
                ha.put(a[i], ha.get(a[i]) + 1);
            }else {
                ha.put(a[i], 1);
            }
        }
        int count = 0;
        for(int k: ha.keySet()) {
            // System.out.println(ha.get(k));
            if(ha.get(k) == 1) {
                count++;
            }
        }
        System.out.println(count);
    }
}
0