結果

問題 No.79 過小評価ダメ・ゼッタイ
ユーザー chiho_miyakochiho_miyako
提出日時 2015-04-09 12:53:44
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 836 bytes
コンパイル時間 2,076 ms
コンパイル使用メモリ 72,520 KB
実行使用メモリ 63,992 KB
最終ジャッジ日時 2023-09-17 18:59:43
合計ジャッジ時間 9,947 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 124 ms
55,980 KB
testcase_03 AC 125 ms
56,440 KB
testcase_04 AC 124 ms
55,468 KB
testcase_05 AC 453 ms
60,320 KB
testcase_06 AC 124 ms
55,916 KB
testcase_07 AC 123 ms
56,104 KB
testcase_08 AC 125 ms
55,492 KB
testcase_09 AC 123 ms
56,208 KB
testcase_10 AC 125 ms
56,004 KB
testcase_11 AC 125 ms
55,932 KB
testcase_12 AC 125 ms
56,080 KB
testcase_13 AC 125 ms
56,096 KB
testcase_14 WA -
testcase_15 AC 281 ms
60,568 KB
testcase_16 WA -
testcase_17 AC 282 ms
60,312 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
権限があれば一括ダウンロードができます

ソースコード

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();
        }
        Arrays.sort(a);
        int count = 0;
        int level = 0;
        int tc = 0;
        for(int i=1; i<n; i++){
            if(a[i]==a[i-1]){
                count = count+1;
                if(count>=tc){
                    level=a[i];
                }
            }else{
                if(count>=tc){
                    tc=count;
                    level=a[i-1];
                    count=0;
                }
            }
        }
        if(tc==0){
            level=a[n-1];
        }
        System.out.println(level);
    }
}
0