結果

問題 No.79 過小評価ダメ・ゼッタイ
ユーザー cra77756176
提出日時 2022-12-06 22:53:18
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 5 ms / 5,000 ms
コード長 594 bytes
コンパイル時間 14,922 ms
コンパイル使用メモリ 377,940 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-13 10:18:09
合計ジャッジ時間 14,347 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::collections::HashMap;

fn main() {
    let mut cc = String::new();
    std::io::Read::read_to_string(&mut std::io::stdin(), &mut cc).ok();
    let cc: Vec<u64> = cc
        .split_whitespace()
        .skip(1)
        .map(|n| n.parse().unwrap())
        .collect();

    let mut votes = HashMap::new();

    for c in cc {
        *votes.entry(c).or_insert(0) += 1;
    }

    let max = votes.values().max().unwrap();
    let answer = votes
        .iter()
        .filter(|&(_, v)| v == max)
        .map(|(k, _)| k)
        .max()
        .unwrap();

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