結果
| 問題 |
No.1708 Quality of Contest
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-10-15 23:42:46 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 194 ms / 2,000 ms |
| コード長 | 1,295 bytes |
| コンパイル時間 | 13,340 ms |
| コンパイル使用メモリ | 385,076 KB |
| 実行使用メモリ | 25,040 KB |
| 最終ジャッジ日時 | 2024-09-17 18:45:48 |
| 合計ジャッジ時間 | 14,583 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge6 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
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);
}