結果

問題 No.112 ややこしい鶴亀算
ユーザー tonyu0
提出日時 2020-03-29 20:14:59
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 811 bytes
コンパイル時間 12,257 ms
コンパイル使用メモリ 390,376 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2025-01-02 15:46:00
合計ジャッジ時間 13,567 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let a: Vec<usize> = (0..n)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();

    let mut map = std::collections::HashMap::new();
    let mut max = 0;
    let mut min = 1 << 30;
    for i in 0..n {
        let p = map.entry(a[i]).or_insert(0);
        *p += 1;
        max = std::cmp::max(max, a[i]);
        min = std::cmp::min(min, a[i]);
    }
    if max == min {
        if 2 * n == 2 + max {
            println!("{} 0", n);
        } else {
            println!("0 {}", n);
        }
    } else {
        println!("{} {}", map[&max], map[&min]);
    }
}
0