結果

問題 No.182 新規性の虜
ユーザー chiho_miyakochiho_miyako
提出日時 2015-04-17 10:45:16
言語 Java19
(openjdk 21)
結果
AC  
実行時間 620 ms / 5,000 ms
コード長 757 bytes
コンパイル時間 3,065 ms
コンパイル使用メモリ 71,788 KB
実行使用メモリ 60,740 KB
最終ジャッジ日時 2023-08-27 07:10:57
合計ジャッジ時間 13,378 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
55,948 KB
testcase_01 AC 128 ms
55,752 KB
testcase_02 AC 127 ms
55,944 KB
testcase_03 AC 128 ms
55,772 KB
testcase_04 AC 128 ms
55,880 KB
testcase_05 AC 131 ms
55,980 KB
testcase_06 AC 126 ms
55,656 KB
testcase_07 AC 129 ms
56,100 KB
testcase_08 AC 487 ms
60,672 KB
testcase_09 AC 620 ms
60,380 KB
testcase_10 AC 562 ms
60,232 KB
testcase_11 AC 544 ms
60,572 KB
testcase_12 AC 407 ms
58,640 KB
testcase_13 AC 128 ms
55,744 KB
testcase_14 AC 131 ms
55,912 KB
testcase_15 AC 126 ms
55,452 KB
testcase_16 AC 127 ms
55,780 KB
testcase_17 AC 131 ms
55,708 KB
testcase_18 AC 528 ms
60,608 KB
testcase_19 AC 436 ms
60,416 KB
testcase_20 AC 381 ms
60,360 KB
testcase_21 AC 516 ms
60,572 KB
testcase_22 AC 403 ms
60,512 KB
testcase_23 AC 126 ms
55,896 KB
testcase_24 AC 525 ms
60,732 KB
testcase_25 AC 450 ms
60,740 KB
testcase_26 AC 288 ms
60,536 KB
testcase_27 AC 125 ms
55,884 KB
evil01.txt AC 583 ms
60,628 KB
evil02.txt AC 584 ms
60,444 KB
権限があれば一括ダウンロードができます

ソースコード

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