結果

問題 No.182 新規性の虜
ユーザー 👑 はまやんはまやんはまやんはまやん
提出日時 2015-06-24 17:27:54
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 664 bytes
コンパイル時間 2,558 ms
コンパイル使用メモリ 72,816 KB
実行使用メモリ 64,616 KB
最終ジャッジ日時 2023-09-22 00:33:27
合計ジャッジ時間 13,137 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
55,912 KB
testcase_01 AC 127 ms
55,784 KB
testcase_02 AC 127 ms
55,704 KB
testcase_03 AC 128 ms
56,084 KB
testcase_04 AC 129 ms
55,784 KB
testcase_05 AC 130 ms
55,684 KB
testcase_06 AC 129 ms
55,900 KB
testcase_07 AC 129 ms
55,676 KB
testcase_08 AC 512 ms
62,660 KB
testcase_09 AC 661 ms
62,600 KB
testcase_10 AC 596 ms
62,680 KB
testcase_11 AC 567 ms
63,188 KB
testcase_12 AC 415 ms
61,048 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 128 ms
55,800 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 125 ms
55,532 KB
testcase_24 AC 585 ms
64,616 KB
testcase_25 AC 488 ms
62,580 KB
testcase_26 AC 293 ms
60,340 KB
testcase_27 AC 125 ms
56,088 KB
evil01.txt AC 653 ms
66,756 KB
evil02.txt AC 659 ms
66,980 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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>();
		
		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