結果

問題 No.349 干支の置き物
コンテスト
ユーザー iwot
提出日時 2020-06-07 16:10:00
言語 Rust
(1.99.0 + proconio + num + itertools + ACL)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
AC  
実行時間 1 ms / 2,000 ms
+ 76µs
コード長 591 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 12,448 ms
コンパイル使用メモリ 182,460 KB
実行使用メモリ 9,900 KB
最終ジャッジ日時 2026-10-15 13:06:27
合計ジャッジ時間 7,738 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge5_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

fn read<T: std::str::FromStr>() -> T {
  let mut s = String::new();
  std::io::stdin().read_line(&mut s).ok();
  s.trim().parse().ok().unwrap()
}

fn main() {
  use std::collections::HashMap;

  let n:usize = read();

  let mut etom = HashMap::new();
  for _i in 0..n {
    let eto:String = read();
    let count = etom.entry(eto).or_insert(0);
    *count += 1;
  }

  let limit = if n % 2 == 0 {
    n / 2
  } else {
    n - n / 2
  };

  let mut result = "YES";
  for (_key, count) in &etom {
    if *count > limit {
      result = "NO";
      break;
    }
  }
  println!("{}", result);
}
0