結果
| 問題 | No.1795 AtCoder Heuristic Rating coloring | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2022-01-07 16:55:15 | 
| 言語 | Rust (1.83.0 + proconio) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 249 ms / 2,000 ms | 
| コード長 | 1,233 bytes | 
| コンパイル時間 | 13,127 ms | 
| コンパイル使用メモリ | 402,660 KB | 
| 実行使用メモリ | 20,860 KB | 
| 最終ジャッジ日時 | 2024-11-14 02:00:01 | 
| 合計ジャッジ時間 | 20,875 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 54 | 
ソースコード
use std::collections::HashMap;
fn main() {
    let mut buf = String::new();
    let mut input = {
        use std::io::Read;
        std::io::stdin().read_to_string(&mut buf).unwrap();
        buf.split_whitespace()
    };
    let n: usize = input.next().unwrap().parse().unwrap();
    let m: usize = input.next().unwrap().parse().unwrap();
    let mut s = vec![];
    let mut a = vec![];
    for _ in 0..n {
        let s_i: String = input.next().unwrap().parse().unwrap();
        let a_i: usize = input.next().unwrap().parse().unwrap();
        s.push(s_i);
        a.push(a_i);
    }
    let mut t = vec![];
    let mut b = vec![];
    for _ in 0..m {
        let t_j: String = input.next().unwrap().parse().unwrap();
        let b_j: usize = input.next().unwrap().parse().unwrap();
        t.push(t_j);
        b.push(b_j);
    }
    let mut rate_map = HashMap::new();
    for i in 0..n {
        rate_map.insert(s[i].clone(), a[i]);
    }
    for j in 0..m {
        rate_map.insert(t[j].clone(), b[j]);
    }
    let mut rate_vec = rate_map.into_iter().collect::<Vec<_>>();
    rate_vec.sort_by(|(key1, _), (key2, _)| key1.cmp(&key2));
    for (name, rate) in &rate_vec {
        println!("{} {}", name, rate);
    }
}
            
            
            
        