結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
55,804 KB
testcase_01 AC 124 ms
56,168 KB
testcase_02 AC 126 ms
55,744 KB
testcase_03 AC 126 ms
55,952 KB
testcase_04 AC 127 ms
55,732 KB
testcase_05 AC 131 ms
53,716 KB
testcase_06 AC 128 ms
55,864 KB
testcase_07 AC 131 ms
55,816 KB
testcase_08 AC 519 ms
62,896 KB
testcase_09 AC 634 ms
62,260 KB
testcase_10 AC 582 ms
62,792 KB
testcase_11 AC 576 ms
62,792 KB
testcase_12 AC 392 ms
60,792 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 125 ms
55,772 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,528 KB
testcase_24 AC 586 ms
65,564 KB
testcase_25 AC 486 ms
61,700 KB
testcase_26 AC 280 ms
60,100 KB
testcase_27 AC 124 ms
55,828 KB
evil01.txt AC 664 ms
66,688 KB
evil02.txt AC 668 ms
66,196 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