結果

問題 No.433 ICPC国内予選の選抜ルールがこんな感じだったらうれしい
ユーザー phsplsphspls
提出日時 2023-01-12 22:20:44
言語 Rust
(1.77.0)
結果
AC  
実行時間 161 ms / 4,000 ms
コード長 1,078 bytes
コンパイル時間 3,028 ms
コンパイル使用メモリ 164,156 KB
実行使用メモリ 31,532 KB
最終ジャッジ日時 2023-08-25 02:49:33
合計ジャッジ時間 8,323 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 139 ms
30,200 KB
testcase_01 AC 118 ms
31,176 KB
testcase_02 AC 68 ms
19,644 KB
testcase_03 AC 93 ms
12,676 KB
testcase_04 AC 95 ms
13,424 KB
testcase_05 AC 90 ms
21,100 KB
testcase_06 AC 161 ms
31,532 KB
testcase_07 AC 88 ms
30,736 KB
testcase_08 AC 74 ms
22,608 KB
testcase_09 AC 75 ms
13,404 KB
testcase_10 AC 83 ms
11,516 KB
testcase_11 AC 104 ms
11,520 KB
testcase_12 AC 97 ms
11,516 KB
testcase_13 AC 56 ms
11,488 KB
testcase_14 AC 77 ms
11,492 KB
testcase_15 AC 50 ms
11,484 KB
testcase_16 AC 117 ms
11,424 KB
testcase_17 AC 111 ms
11,520 KB
testcase_18 AC 123 ms
11,464 KB
testcase_19 AC 57 ms
11,504 KB
testcase_20 AC 69 ms
11,512 KB
testcase_21 AC 62 ms
11,408 KB
testcase_22 AC 99 ms
11,488 KB
testcase_23 AC 78 ms
11,524 KB
testcase_24 AC 55 ms
11,536 KB
testcase_25 AC 93 ms
11,508 KB
testcase_26 AC 70 ms
11,416 KB
testcase_27 AC 91 ms
11,484 KB
testcase_28 AC 52 ms
11,532 KB
testcase_29 AC 100 ms
11,524 KB
testcase_30 AC 1 ms
4,380 KB
testcase_31 AC 1 ms
4,376 KB
testcase_32 AC 110 ms
11,532 KB
testcase_33 AC 116 ms
11,552 KB
testcase_34 AC 63 ms
12,892 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,376 KB
testcase_40 AC 2 ms
4,376 KB
testcase_41 AC 6 ms
4,376 KB
testcase_42 AC 6 ms
4,376 KB
testcase_43 AC 7 ms
4,376 KB
testcase_44 AC 7 ms
4,376 KB
testcase_45 AC 3 ms
4,376 KB
testcase_46 AC 19 ms
4,380 KB
testcase_47 AC 19 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused variable: `u`
  --> Main.rs:23:11
   |
23 |     for (&u, btree) in mapping.iter() {
   |           ^ help: if this is intentional, prefix it with an underscore: `_u`
   |
   = note: `#[warn(unused_variables)]` on by default

warning: 1 warning emitted

ソースコード

diff #

use std::{collections::{HashMap, BinaryHeap, BTreeSet}, 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, &(s, p, u)) in teams.iter().enumerate() {
        mapping.entry(u).or_insert(BTreeSet::new()).insert((s, Reverse(p), i));
    }
    let mut pque = BinaryHeap::new();
    for (&u, btree) in mapping.iter() {
        for (i, &(s, revp, idx)) in btree.iter().rev().enumerate() {
            pque.push((s, Reverse(i), revp, idx));
        }
    }
    for _ in 0..k {
        println!("{}", pque.pop().unwrap().3);
    }
}
0