結果
問題 |
No.2957 Combo Deck Builder
|
ユーザー |
|
提出日時 | 2024-11-08 23:13:28 |
言語 | Rust (1.83.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,100 bytes |
コンパイル時間 | 13,966 ms |
コンパイル使用メモリ | 378,268 KB |
実行使用メモリ | 18,048 KB |
最終ジャッジ日時 | 2024-11-08 23:13:47 |
合計ジャッジ時間 | 19,289 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 10 WA * 28 |
ソースコード
use std::collections::BinaryHeap; use proconio::input; fn main() { input! { n: usize, cxy: [(usize, i64, i64); n], } let mut score = 0_i64; let mut heap: BinaryHeap<Node> = cxy.iter().map(|&(c, x, y)| Node::new(c, x, y)).collect(); let mut cnt = 0_usize; while let Some(node) = heap.pop() { score += if cnt >= node.c { node.x } else { node.y }; cnt += 1; } println!("{}", score); } #[derive(Debug, Clone, Copy)] struct Node { c: usize, x: i64, y: i64, diff: i64, } impl PartialEq for Node { fn eq(&self, other: &Self) -> bool { self.diff == other.diff } } impl Eq for Node {} impl PartialOrd for Node { fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> { Some(self.cmp(&other)) } } impl Ord for Node { fn cmp(&self, other: &Self) -> std::cmp::Ordering { self.diff.cmp(&other.diff) } } impl Node { fn new(c: usize, x: i64, y: i64) -> Self { Self { c, x, y, diff: y - x, } } }