結果

問題 No.79 過小評価ダメ・ゼッタイ
コンテスト
ユーザー YamaKasa
提出日時 2018-04-21 21:01:09
言語 Java
(openjdk 25.0.2)
コンパイル:
javac -encoding UTF8 _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true _class_
結果
AC  
実行時間 314 ms / 5,000 ms
コード長 577 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,755 ms
コンパイル使用メモリ 82,824 KB
実行使用メモリ 56,028 KB
最終ジャッジ日時 2026-03-14 12:55:05
合計ジャッジ時間 6,589 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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