結果

問題 No.79 過小評価ダメ・ゼッタイ
ユーザー chiho_miyako
提出日時 2015-04-09 12:53:44
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 836 bytes
コンパイル時間 2,149 ms
コンパイル使用メモリ 75,324 KB
実行使用メモリ 59,648 KB
最終ジャッジ日時 2024-07-04 13:23:20
合計ジャッジ時間 10,517 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 11 WA * 11
権限があれば一括ダウンロードができます

ソースコード

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