結果

問題 No.182 新規性の虜
ユーザー Eve_daoda
提出日時 2015-08-04 13:41:56
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 871 bytes
コンパイル時間 3,540 ms
コンパイル使用メモリ 75,796 KB
実行使用メモリ 63,624 KB
最終ジャッジ日時 2024-07-18 01:14:07
合計ジャッジ時間 15,381 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18 WA * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.HashSet;
import java.util.Scanner;
public class nn {
    public static int ans(int[] A){
        int cnt = 0;
        boolean flag = false;
        HashSet<Integer> cheack = new HashSet<Integer>();
        for(int now : A){
            if (!cheack.contains(now)) {
                cheack.add(now);
                cnt++;
                flag = true;
            }
            else {
                if (flag) {
                    cnt--;
                    flag = false;
                }
            }
        }
        
        if(cnt > 0) return cnt; else return 0;
    }
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int a[] = new int[N];
        for (int i = 0; i < N; i++) {
            a[i] = sc.nextInt();
        }
        System.out.println(ans(a));
    }
}
0