結果
| 問題 |
No.628 Tagの勢い
|
| コンテスト | |
| ユーザー |
H20
|
| 提出日時 | 2022-09-09 13:48:50 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 914 bytes |
| コンパイル時間 | 15,949 ms |
| コンパイル使用メモリ | 401,292 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-25 10:34:07 |
| 合計ジャッジ時間 | 14,133 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 |
コンパイルメッセージ
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`
ソースコード
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)
}
}
H20