結果
問題 | No.182 新規性の虜 |
ユーザー |
![]() |
提出日時 | 2017-02-27 22:23:54 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 1,008 ms / 5,000 ms |
コード長 | 1,239 bytes |
コンパイル時間 | 3,853 ms |
コンパイル使用メモリ | 76,640 KB |
実行使用メモリ | 54,488 KB |
最終ジャッジ日時 | 2024-12-27 12:36:34 |
合計ジャッジ時間 | 20,148 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
ソースコード
import java.util.Scanner; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); /* int[] a = new int[n]; for(int i=0; i<n; i++) { a[i] = in.nextInt(); } int cnt = 0; for(int i=0; i<n; i++) { boolean flag = true; for(int j=0; j<n; j++) { if(i != j && a[i] == a[j]) { flag = false; break; } } if(flag) cnt++; } System.out.println(cnt); */ HashMap<Integer, Integer> map = new HashMap<Integer, Integer>(); for(int i=0; i<n; i++) { int a = in.nextInt(); if(map.containsKey(a)) { map.put(a, (map.get(a) + 1)); } else { map.put(a, 1); } } int cnt = 0; for(int key : map.keySet()) { if(map.get(key) == 1) { cnt++; } } System.out.println(cnt); in.close(); } }