結果

問題 No.628 Tagの勢い
ユーザー 👑 H20H20
提出日時 2022-09-09 13:48:50
言語 Rust
(1.77.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 914 bytes
コンパイル時間 14,757 ms
コンパイル使用メモリ 403,472 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-04 03:54:14
合計ジャッジ時間 14,854 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 0 ms
6,940 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 0 ms
6,940 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 1 ms
6,944 KB
testcase_07 AC 0 ms
6,940 KB
testcase_08 AC 1 ms
6,940 KB
testcase_09 AC 1 ms
6,940 KB
testcase_10 AC 1 ms
6,940 KB
testcase_11 AC 1 ms
6,944 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 1 ms
6,944 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 1 ms
6,944 KB
testcase_16 AC 1 ms
6,940 KB
testcase_17 AC 1 ms
6,940 KB
testcase_18 AC 1 ms
6,940 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused variable: `i`
  --> src/main.rs:12:9
   |
12 |     for i in 0..n{       
   |         ^ help: if this is intentional, prefix it with an underscore: `_i`
   |
   = note: `#[warn(unused_variables)]` on by default

warning: unused variable: `ni`
  --> src/main.rs:13:13
   |
13 |         let ni: usize = iter.next().unwrap().parse().unwrap();
   |             ^^ help: if this is intentional, prefix it with an underscore: `_ni`

warning: unused variable: `j`
  --> src/main.rs:16:13
   |
16 |         for j in 0..m{
   |             ^ help: if this is intentional, prefix it with an underscore: `_j`

ソースコード

diff #

use std::io::Read;
use std::cmp::min;
use std::collections::HashMap;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();

    let n: usize = iter.next().unwrap().parse().unwrap();
    let mut score: HashMap<String, isize> = HashMap::new();
    for i in 0..n{       
        let ni: usize = iter.next().unwrap().parse().unwrap();
        let m: usize = iter.next().unwrap().parse().unwrap();
        let s: isize = iter.next().unwrap().parse().unwrap();
        for j in 0..m{
            let tag =  iter.next().unwrap().parse::<String>().unwrap();
            *score.entry(tag).or_default() += s;
        }
    }
    let mut vec: Vec<(_, _)> = score.iter().collect();
    vec.sort_by(|a, b| (-a.1).cmp(&(-b.1)).then(a.0.cmp(&b.0)));
    for i in 0..min(10,vec.len()){
        println!("{} {}",vec[i].0,vec[i].1)
    }

}
0