結果

問題 No.182 新規性の虜
ユーザー 👑 はまやんはまやんはまやんはまやん
提出日時 2015-06-24 17:51:29
言語 Java21
(openjdk 21)
結果
AC  
実行時間 665 ms / 5,000 ms
コード長 710 bytes
コンパイル時間 4,542 ms
コンパイル使用メモリ 72,928 KB
実行使用メモリ 64,744 KB
最終ジャッジ日時 2023-08-27 07:23:59
合計ジャッジ時間 15,767 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
55,864 KB
testcase_01 AC 125 ms
54,076 KB
testcase_02 AC 124 ms
56,280 KB
testcase_03 AC 129 ms
55,776 KB
testcase_04 AC 130 ms
55,548 KB
testcase_05 AC 130 ms
56,132 KB
testcase_06 AC 128 ms
56,180 KB
testcase_07 AC 128 ms
56,416 KB
testcase_08 AC 543 ms
63,620 KB
testcase_09 AC 665 ms
63,044 KB
testcase_10 AC 618 ms
63,424 KB
testcase_11 AC 609 ms
61,696 KB
testcase_12 AC 419 ms
60,876 KB
testcase_13 AC 126 ms
56,008 KB
testcase_14 AC 131 ms
55,784 KB
testcase_15 AC 125 ms
56,088 KB
testcase_16 AC 127 ms
56,196 KB
testcase_17 AC 131 ms
55,876 KB
testcase_18 AC 510 ms
60,716 KB
testcase_19 AC 442 ms
60,264 KB
testcase_20 AC 384 ms
60,348 KB
testcase_21 AC 567 ms
60,344 KB
testcase_22 AC 405 ms
60,432 KB
testcase_23 AC 125 ms
55,928 KB
testcase_24 AC 576 ms
64,744 KB
testcase_25 AC 497 ms
60,424 KB
testcase_26 AC 298 ms
60,580 KB
testcase_27 AC 126 ms
55,784 KB
evil01.txt AC 659 ms
66,752 KB
evil02.txt AC 658 ms
66,876 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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));
	}
}
0