結果

問題 No.1708 Quality of Contest
ユーザー tonyu0tonyu0
提出日時 2021-10-15 23:42:46
言語 Rust
(1.77.0)
結果
AC  
実行時間 85 ms / 2,000 ms
コード長 1,295 bytes
コンパイル時間 1,924 ms
コンパイル使用メモリ 167,944 KB
実行使用メモリ 25,168 KB
最終ジャッジ日時 2023-10-17 21:33:12
合計ジャッジ時間 4,517 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 79 ms
25,168 KB
testcase_10 AC 50 ms
17,384 KB
testcase_11 AC 65 ms
15,988 KB
testcase_12 AC 69 ms
17,076 KB
testcase_13 AC 62 ms
15,052 KB
testcase_14 AC 69 ms
17,768 KB
testcase_15 AC 85 ms
21,936 KB
testcase_16 AC 84 ms
21,552 KB
testcase_17 AC 73 ms
18,456 KB
testcase_18 AC 74 ms
18,736 KB
testcase_19 AC 77 ms
19,992 KB
testcase_20 AC 70 ms
18,196 KB
testcase_21 AC 73 ms
19,152 KB
testcase_22 AC 69 ms
17,860 KB
testcase_23 AC 82 ms
21,680 KB
testcase_24 AC 47 ms
13,500 KB
testcase_25 AC 48 ms
13,412 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let m: usize = itr.next().unwrap().parse().unwrap();
    let x: usize = itr.next().unwrap().parse().unwrap();
    let mut a = vec![0; n];
    let mut b = vec![0; n];
    let mut g = vec![Vec::new(); m + 1];
    let mut costs = Vec::new();
    for i in 0..n {
        a[i] = itr.next().unwrap().parse().unwrap();
        b[i] = itr.next().unwrap().parse::<usize>().unwrap() - 1;
        g[b[i]].push(a[i]);
    }
    for i in 0..m {
        if g[i].len() > 0 {
            g[i].sort_by_key(|&x| std::cmp::Reverse(x));
            g[i][0] += x;
            for j in 0..g[i].len() {
                costs.push(g[i][j]);
            }
        }
    }
    costs.sort_by_key(|&x| std::cmp::Reverse(x));
    for i in 1..costs.len() {
        costs[i] += costs[i - 1];
    }

    let k: usize = itr.next().unwrap().parse().unwrap();
    let mut ans = 0;
    for _ in 0..k {
        let c: usize = itr.next().unwrap().parse().unwrap();
        if c == 0 {
            continue;
        }
        ans += costs[std::cmp::min(costs.len(), c) - 1];
    }
    println!("{}", ans);
}
0