結果

問題 No.182 新規性の虜
ユーザー koukonko
提出日時 2015-12-14 13:42:33
言語 Java
(openjdk 23)
結果
AC  
実行時間 423 ms / 5,000 ms
コード長 854 bytes
コンパイル時間 2,776 ms
コンパイル使用メモリ 77,720 KB
実行使用メモリ 52,784 KB
最終ジャッジ日時 2024-12-26 19:59:44
合計ジャッジ時間 9,660 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {
	public static void main(String[] args) {
		BufferedReader read = new BufferedReader(new InputStreamReader(System.in));
		try {

			int N = Integer.parseInt(read.readLine());
			String[] line = read.readLine().split(" ");
			List<Integer> list = new ArrayList<>(N);

			list.add(0);
			for (int i = 0; i < N; ++i) {
				list.add(Integer.parseInt(line[i]));
			}
			list.add(Integer.MAX_VALUE);
			list.sort(null);

			int ans = 0;
			for (int i = 1; i <= N; ++i) {
				if (list.get(i - 1).intValue() != list.get(i).intValue() && list.get(i + 1).intValue() != list.get(i).intValue()) {
					++ans;
				}
			}

			System.out.println(ans);

		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
0