結果

問題 No.182 新規性の虜
ユーザー chiho_miyako
提出日時 2015-04-17 10:45:16
言語 Java
(openjdk 23)
結果
AC  
実行時間 830 ms / 5,000 ms
コード長 757 bytes
コンパイル時間 4,119 ms
コンパイル使用メモリ 74,640 KB
実行使用メモリ 48,640 KB
最終ジャッジ日時 2024-12-26 18:56:22
合計ジャッジ時間 16,382 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner koko = new Scanner(System.in);
        int n = koko.nextInt();
        int[] a = new int[n];
        for(int i=0; i<n; i++){
            a[i]=koko.nextInt();
        }
        if(n==1){
            System.out.println(1);
        }else{
            Arrays.sort(a);
            int count=0;
            if(a[0]!=a[1]){
                count=1;
           }
            for(int i=1; i<n-1; i++){
                if(a[i]!=a[i-1]&&a[i]!=a[i+1]){
                    count++;
                }
            }
            if(a[n-1]!=a[n-2]){
                count++;
            }
            System.out.println(count);
        }
        
    }
}
0