結果
問題 | No.182 新規性の虜 |
ユーザー |
![]() |
提出日時 | 2015-06-24 17:51:29 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 912 ms / 5,000 ms |
コード長 | 710 bytes |
コンパイル時間 | 4,443 ms |
コンパイル使用メモリ | 80,060 KB |
実行使用メモリ | 52,884 KB |
最終ジャッジ日時 | 2024-12-26 19:26:05 |
合計ジャッジ時間 | 17,820 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
ソースコード
import java.util.Arrays; import java.util.HashSet; import java.util.Scanner; public class Main { public static int solve(int[] A){ int count = 0; boolean flag = false; HashSet<Integer> cheack = new HashSet<Integer>(); Arrays.sort(A); for(int now : A){ if (!cheack.contains(now)) { cheack.add(now); count++; flag = true; } else { if (flag) { count--; } flag = false; } } if(count > 0) return count; else return 0; } public static void main(String[] args){ Scanner S = new Scanner(System.in); int N = S.nextInt(); int A[] = new int[N]; for (int i = 0; i < N; i++) { A[i] = S.nextInt(); } System.out.println(solve(A)); } }