結果

問題 No.79 過小評価ダメ・ゼッタイ
ユーザー dnikkdnikk
提出日時 2018-07-17 12:11:17
言語 Rust
(1.72.1)
結果
AC  
実行時間 6 ms / 5,000 ms
コード長 826 bytes
コンパイル時間 1,536 ms
コンパイル使用メモリ 156,220 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-08-16 06:21:49
合計ジャッジ時間 3,260 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 5 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 5 ms
4,380 KB
testcase_06 AC 1 ms
4,388 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,384 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,384 KB
testcase_14 AC 4 ms
4,384 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 4 ms
4,384 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 4 ms
4,380 KB
testcase_19 AC 3 ms
4,380 KB
testcase_20 AC 6 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 3 ms
4,384 KB
testcase_23 AC 5 ms
4,384 KB
testcase_24 AC 5 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

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