結果

問題 No.433 ICPC国内予選の選抜ルールがこんな感じだったらうれしい
ユーザー phsplsphspls
提出日時 2023-01-20 01:20:24
言語 Rust
(1.77.0)
結果
AC  
実行時間 147 ms / 4,000 ms
コード長 1,143 bytes
コンパイル時間 2,372 ms
コンパイル使用メモリ 160,548 KB
実行使用メモリ 17,288 KB
最終ジャッジ日時 2023-09-04 20:52:58
合計ジャッジ時間 9,148 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 138 ms
16,188 KB
testcase_01 AC 102 ms
16,428 KB
testcase_02 AC 58 ms
12,388 KB
testcase_03 AC 94 ms
9,980 KB
testcase_04 AC 93 ms
9,856 KB
testcase_05 AC 77 ms
12,508 KB
testcase_06 AC 147 ms
17,288 KB
testcase_07 AC 77 ms
16,796 KB
testcase_08 AC 60 ms
12,644 KB
testcase_09 AC 68 ms
9,268 KB
testcase_10 AC 79 ms
9,092 KB
testcase_11 AC 101 ms
8,648 KB
testcase_12 AC 91 ms
8,972 KB
testcase_13 AC 50 ms
9,036 KB
testcase_14 AC 70 ms
8,820 KB
testcase_15 AC 44 ms
8,500 KB
testcase_16 AC 113 ms
8,684 KB
testcase_17 AC 108 ms
9,016 KB
testcase_18 AC 113 ms
9,032 KB
testcase_19 AC 50 ms
8,984 KB
testcase_20 AC 61 ms
9,064 KB
testcase_21 AC 56 ms
8,916 KB
testcase_22 AC 91 ms
8,776 KB
testcase_23 AC 72 ms
8,772 KB
testcase_24 AC 47 ms
8,812 KB
testcase_25 AC 85 ms
8,800 KB
testcase_26 AC 64 ms
8,684 KB
testcase_27 AC 86 ms
8,476 KB
testcase_28 AC 46 ms
9,044 KB
testcase_29 AC 98 ms
8,804 KB
testcase_30 AC 1 ms
4,380 KB
testcase_31 AC 1 ms
4,376 KB
testcase_32 AC 106 ms
9,176 KB
testcase_33 AC 113 ms
8,732 KB
testcase_34 AC 56 ms
9,728 KB
testcase_35 AC 1 ms
4,376 KB
testcase_36 AC 1 ms
4,376 KB
testcase_37 AC 1 ms
4,376 KB
testcase_38 AC 1 ms
4,380 KB
testcase_39 AC 2 ms
4,384 KB
testcase_40 AC 2 ms
4,380 KB
testcase_41 AC 7 ms
4,376 KB
testcase_42 AC 6 ms
4,376 KB
testcase_43 AC 6 ms
4,376 KB
testcase_44 AC 7 ms
4,380 KB
testcase_45 AC 3 ms
4,380 KB
testcase_46 AC 19 ms
4,376 KB
testcase_47 AC 19 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused variable: `s`
  --> Main.rs:20:14
   |
20 |         let (s, p, u) = teams[i];
   |              ^ help: if this is intentional, prefix it with an underscore: `_s`
   |
   = note: `#[warn(unused_variables)]` on by default

warning: unused variable: `p`
  --> Main.rs:20:17
   |
20 |         let (s, p, u) = teams[i];
   |                 ^ help: if this is intentional, prefix it with an underscore: `_p`

warning: unused variable: `key`
  --> Main.rs:24:11
   |
24 |     for (&key, v) in mapping.iter_mut() {
   |           ^^^ help: if this is intentional, prefix it with an underscore: `_key`

warning: 3 warnings emitted

ソースコード

diff #

use std::{collections::{HashMap, BinaryHeap}, cmp::Reverse};


fn main() {
    let mut nk = String::new();
    std::io::stdin().read_line(&mut nk).ok();
    let nk: Vec<usize> = nk.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let n = nk[0];
    let k = nk[1];
    let teams = (0..n).map(|_| {
            let mut temp = String::new();
            std::io::stdin().read_line(&mut temp).ok();
            let temp: Vec<usize> = temp.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
            (temp[0], temp[1], temp[2])
        })
        .collect::<Vec<_>>();

    let mut mapping = HashMap::new();
    for i in 0..n {
        let (s, p, u) = teams[i];
        mapping.entry(u).or_insert(vec![]).push(i);
    }
    let mut pque = BinaryHeap::new();
    for (&key, v) in mapping.iter_mut() {
        v.sort_by_key(|&i| (Reverse(teams[i].0), teams[i].1));
        for i in 0..v.len() {
            let tidx = v[i];
            let (s, p, _) = teams[tidx];
            pque.push((s, Reverse(i), Reverse(p), tidx));
        }
    }
    for _ in 0..k {
        println!("{}", pque.pop().unwrap().3);
    }
}
0