結果

問題 No.79 過小評価ダメ・ゼッタイ
ユーザー dnikkdnikk
提出日時 2018-07-17 12:11:17
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 6 ms / 5,000 ms
コード長 826 bytes
コンパイル時間 12,103 ms
コンパイル使用メモリ 404,396 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-24 17:06:09
合計ジャッジ時間 13,211 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::collections::HashMap;

fn main() {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input).ok();

    let mut input = String::new();
    std::io::stdin().read_line(&mut input).ok();

    let l_vec = input
        .split_whitespace()
        .map(|x| x.parse::<i64>().unwrap())
        .collect::<Vec<_>>();

    let mut l_with_count = HashMap::new();
    for l in l_vec {
        let counter = l_with_count.entry(l).or_insert(0);
        *counter += 1;
    }

    let answer = l_with_count
        .iter()
        .max_by(|x, y| {
            let ((x_key, x_val), (y_key, y_val)) = (x, y);
            if x_val == y_val {
                x_key.cmp(y_key)
            } else {
                x_val.cmp(y_val)
            }
        })
        .unwrap()
        .0;

    println!("{}", answer);
}
0