結果

問題 No.79 過小評価ダメ・ゼッタイ
ユーザー chiho_miyako
提出日時 2015-04-11 20:48:53
言語 Java
(openjdk 23)
結果
AC  
実行時間 577 ms / 5,000 ms
コード長 784 bytes
コンパイル時間 2,355 ms
コンパイル使用メモリ 74,132 KB
実行使用メモリ 48,160 KB
最終ジャッジ日時 2024-06-26 07:31:23
合計ジャッジ時間 10,971 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

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[] l = new int[n];
        for(int i=0; i<n; i++){
            l[i] = koko.nextInt();
        }
        Arrays.sort(l);
        int count = 0;
        int max = 0;
        int now = l[0];
        for(int i=1; i<n; i++){
            if(l[i]==l[i-1]){
                count = count+1;
                if(count>=max){
                    max=count;
                    now=l[i];
                }
            }else{
                count=0;
            }
        }
        if(max==0){
            System.out.println(l[n-1]);
        }else{
            System.out.println(now);
        }
    }
}
0