結果
問題 | No.2957 Combo Deck Builder |
ユーザー | 37kt |
提出日時 | 2024-11-20 12:31:24 |
言語 | Rust (1.77.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,526 bytes |
コンパイル時間 | 13,225 ms |
コンパイル使用メモリ | 395,012 KB |
実行使用メモリ | 13,332 KB |
最終ジャッジ日時 | 2024-11-20 12:31:45 |
合計ジャッジ時間 | 21,325 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,816 KB |
testcase_01 | AC | 1 ms
6,820 KB |
testcase_02 | AC | 1 ms
6,820 KB |
testcase_03 | WA | - |
testcase_04 | AC | 1 ms
6,816 KB |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | AC | 32 ms
7,040 KB |
testcase_31 | AC | 28 ms
6,816 KB |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | AC | 51 ms
11,476 KB |
testcase_35 | AC | 51 ms
11,684 KB |
testcase_36 | WA | - |
testcase_37 | AC | 1 ms
6,816 KB |
testcase_38 | AC | 1 ms
6,820 KB |
testcase_39 | AC | 1 ms
6,816 KB |
ソースコード
pub use __cargo_equip::prelude::*; use std::collections::BinaryHeap; use chminmax::chmax; #[allow(unused_imports)] use proconio::{ input, marker::{Bytes, Chars, Usize1}, }; fn main() { input! { n: usize, } let mut base = 0; let mut vl = vec![]; let mut vr = vec![]; for _ in 0..n { input! { c: usize, x: usize, y: usize, } if x >= y { base += y; if c != n { vr.push((c, x - y)); } } else { base += x; if c != 0 { vr.push((n - c, y - x)); } } } vl.sort_unstable(); vr.sort_unstable(); let mut res_v = vec![]; for mut v in [vl, vr] { let mut res = vec![0; n + 1]; let mut sum = 0; let mut pq = BinaryHeap::new(); for d in (0..v.len()).rev() { while v.len() > 0 && v.last().unwrap().0 >= d { pq.push(v.pop().unwrap().1); } sum += pq.pop().unwrap_or_default(); res[d + 1] = sum; } res_v.push(res); } let mut res = 0; for i in 0..=n { chmax!(res, base + res_v[0][i] + res_v[1][n - i]); } println!("{}", res); } // The following code was expanded by `cargo-equip`. /// # Bundled libraries /// /// - `chminmax 0.1.0 (path+████████████████████████████████████████████████████)` published in **missing** licensed under `CC0-1.0` as `crate::__cargo_equip::crates::chminmax` #[cfg_attr(any(), rustfmt::skip)] #[allow(unused)] mod __cargo_equip { pub(crate) mod crates { pub mod chminmax {pub use crate::__cargo_equip::macros::chminmax::*;#[macro_export]macro_rules!__cargo_equip_macro_def_chminmax_min{($a:expr$(,)*)=>{{$a}};($a:expr,$b:expr$(,)*)=>{{std::cmp::min($a,$b)}};($a:expr,$($rest:expr),+$(,)*)=>{{std::cmp::min($a,$crate::__cargo_equip::crates::chminmax::min!($($rest),+))}};}macro_rules!min{($($tt:tt)*)=>(crate::__cargo_equip_macro_def_chminmax_min!{$($tt)*})}#[macro_export]macro_rules!__cargo_equip_macro_def_chminmax_max{($a:expr$(,)*)=>{{$a}};($a:expr,$b:expr$(,)*)=>{{std::cmp::max($a,$b)}};($a:expr,$($rest:expr),+$(,)*)=>{{std::cmp::max($a,$crate::__cargo_equip::crates::chminmax::max!($($rest),+))}};}macro_rules!max{($($tt:tt)*)=>(crate::__cargo_equip_macro_def_chminmax_max!{$($tt)*})}#[macro_export]macro_rules!__cargo_equip_macro_def_chminmax_chmin{($base:expr,$($cmps:expr),+$(,)*)=>{{let cmp_min=$crate::__cargo_equip::crates::chminmax::min!($($cmps),+);if$base>cmp_min{$base=cmp_min;true}else{false}}};}macro_rules!chmin{($($tt:tt)*)=>(crate::__cargo_equip_macro_def_chminmax_chmin!{$($tt)*})}#[macro_export]macro_rules!__cargo_equip_macro_def_chminmax_chmax{($base:expr,$($cmps:expr),+$(,)*)=>{{let cmp_max=$crate::__cargo_equip::crates::chminmax::max!($($cmps),+);if$base<cmp_max{$base=cmp_max;true}else{false}}};}macro_rules!chmax{($($tt:tt)*)=>(crate::__cargo_equip_macro_def_chminmax_chmax!{$($tt)*})}} } pub(crate) mod macros { pub mod chminmax {pub use crate::{__cargo_equip_macro_def_chminmax_chmax as chmax,__cargo_equip_macro_def_chminmax_chmin as chmin,__cargo_equip_macro_def_chminmax_max as max,__cargo_equip_macro_def_chminmax_min as min};} } pub(crate) mod prelude {pub use crate::__cargo_equip::crates::*;} mod preludes { pub mod chminmax {} } }