結果
問題 | No.182 新規性の虜 |
ユーザー |
![]() |
提出日時 | 2015-04-16 23:35:00 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 215 ms / 5,000 ms |
コード長 | 868 bytes |
コンパイル時間 | 2,409 ms |
コンパイル使用メモリ | 76,620 KB |
実行使用メモリ | 40,564 KB |
最終ジャッジ日時 | 2024-12-26 18:47:26 |
合計ジャッジ時間 | 6,999 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
ソースコード
import java.io.IOException; import java.util.Arrays; public class Main { public static void main(String[] args) throws Exception { int N = nextInt(); int[] input = new int[N]; for (int i = 0; i < N; i++) { input[i] = nextInt(); } Arrays.sort(input); int ans = 0; for (int i = 0; i < N; i++) { if ((i == 0 || input[i - 1] != input[i]) && (i == N - 1 || input[i] != input[i + 1])) { ans++; } } System.out.println(ans); } static int nextInt() { int c; try { c = System.in.read(); while (c != '-' && (c < '0' || c > '9')) c = System.in.read(); if (c == '-') return -nextInt(); int res = 0; while (c >= '0' && c <= '9') { res = res * 10 + c - '0'; c = System.in.read(); } return res; } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return -1; } }