結果

問題 No.79 過小評価ダメ・ゼッタイ
ユーザー YamaKasa
提出日時 2018-04-21 21:01:09
言語 Java
(openjdk 23)
結果
AC  
実行時間 562 ms / 5,000 ms
コード長 577 bytes
コンパイル時間 1,966 ms
コンパイル使用メモリ 74,516 KB
実行使用メモリ 48,664 KB
最終ジャッジ日時 2024-06-27 05:28:27
合計ジャッジ時間 10,368 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int []L = new int[N];
		for(int i = 0; i < N; i++) {
			L[i] = scan.nextInt();
		}
		scan.close();
		Arrays.sort(L);
		int ans = L[0];
		int temp = L[0];
		int cnt1 = 1;
		int cnt2 = 1;
		for(int i = 1; i < N; i++) {
			if(temp == L[i]) {
				cnt1 ++;
			}else {
				temp = L[i];
				cnt1 = 1;
			}
			if(cnt1 >= cnt2) {
				cnt2 = cnt1;
				ans = L[i];
			}
		}
		System.out.println(ans);
	}
}
0