結果
| 問題 |
No.3197 Frequency Counter
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-07-12 15:45:22 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 310 ms / 2,000 ms |
| コード長 | 1,389 bytes |
| コンパイル時間 | 23,542 ms |
| コンパイル使用メモリ | 383,616 KB |
| 実行使用メモリ | 14,892 KB |
| 最終ジャッジ日時 | 2025-07-12 15:45:52 |
| 合計ジャッジ時間 | 28,615 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 21 |
ソースコード
use std::io::{self, BufRead};
use std::collections::HashMap;
fn main() {
let stdin = io::stdin();
let mut lines = stdin.lock().lines();
// Nを読み込み
let _n: usize = lines.next().unwrap().unwrap().parse().unwrap();
// 数列Aを読み込み
let line = lines.next().unwrap().unwrap();
let a: Vec<i64> = line.split_whitespace()
.map(|x| x.parse().unwrap())
.collect();
// 各数の出現回数をカウント
let mut count_map = HashMap::new();
for &num in &a {
*count_map.entry(num).or_insert(0) += 1;
}
// Qを読み込み
let q: usize = lines.next().unwrap().unwrap().parse().unwrap();
// 結果を保存するベクター
let mut results = Vec::new();
// 各クエリを処理
for _ in 0..q {
let line = lines.next().unwrap().unwrap();
let parts: Vec<&str> = line.split_whitespace().collect();
let x: i64 = parts[0].parse().unwrap();
let k: usize = parts[1].parse().unwrap();
// 出現回数を取得
let count = count_map.get(&x).unwrap_or(&0);
// 結果を保存
if *count >= k {
results.push("Yes");
} else {
results.push("No");
}
}
// 結果をまとめて出力
for result in results {
println!("{}", result);
}
}