結果

問題 No.79 過小評価ダメ・ゼッタイ
ユーザー chiho_miyakochiho_miyako
提出日時 2015-04-11 20:48:53
言語 Java21
(openjdk 21)
結果
AC  
実行時間 466 ms / 5,000 ms
コード長 784 bytes
コンパイル時間 2,045 ms
コンパイル使用メモリ 71,452 KB
実行使用メモリ 62,732 KB
最終ジャッジ日時 2023-09-08 14:24:39
合計ジャッジ時間 9,840 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 208 ms
58,896 KB
testcase_01 AC 466 ms
60,528 KB
testcase_02 AC 122 ms
56,148 KB
testcase_03 AC 121 ms
55,996 KB
testcase_04 AC 120 ms
55,984 KB
testcase_05 AC 456 ms
60,588 KB
testcase_06 AC 126 ms
55,980 KB
testcase_07 AC 127 ms
56,092 KB
testcase_08 AC 122 ms
56,100 KB
testcase_09 AC 122 ms
55,964 KB
testcase_10 AC 123 ms
56,188 KB
testcase_11 AC 125 ms
55,924 KB
testcase_12 AC 124 ms
56,056 KB
testcase_13 AC 130 ms
55,864 KB
testcase_14 AC 388 ms
60,388 KB
testcase_15 AC 289 ms
60,392 KB
testcase_16 AC 407 ms
60,660 KB
testcase_17 AC 284 ms
60,200 KB
testcase_18 AC 425 ms
62,732 KB
testcase_19 AC 365 ms
60,316 KB
testcase_20 AC 464 ms
60,956 KB
testcase_21 AC 192 ms
58,688 KB
testcase_22 AC 320 ms
60,776 KB
testcase_23 AC 436 ms
60,516 KB
testcase_24 AC 440 ms
60,284 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[] 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