結果
問題 | No.2730 Two Types Luggage |
ユーザー | tipstar0125 |
提出日時 | 2024-04-19 21:47:34 |
言語 | Rust (1.77.0 + proconio) |
結果 |
AC
|
実行時間 | 284 ms / 2,000 ms |
コード長 | 5,280 bytes |
コンパイル時間 | 29,650 ms |
コンパイル使用メモリ | 377,708 KB |
実行使用メモリ | 32,860 KB |
最終ジャッジ日時 | 2024-10-11 14:43:45 |
合計ジャッジ時間 | 21,623 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
5,248 KB |
testcase_01 | AC | 1 ms
5,248 KB |
testcase_02 | AC | 1 ms
5,248 KB |
testcase_03 | AC | 1 ms
5,248 KB |
testcase_04 | AC | 1 ms
5,248 KB |
testcase_05 | AC | 1 ms
5,248 KB |
testcase_06 | AC | 1 ms
5,248 KB |
testcase_07 | AC | 1 ms
5,248 KB |
testcase_08 | AC | 1 ms
5,248 KB |
testcase_09 | AC | 1 ms
5,248 KB |
testcase_10 | AC | 8 ms
5,248 KB |
testcase_11 | AC | 199 ms
24,576 KB |
testcase_12 | AC | 281 ms
31,564 KB |
testcase_13 | AC | 155 ms
19,968 KB |
testcase_14 | AC | 208 ms
24,576 KB |
testcase_15 | AC | 54 ms
7,680 KB |
testcase_16 | AC | 72 ms
9,984 KB |
testcase_17 | AC | 260 ms
30,428 KB |
testcase_18 | AC | 237 ms
27,680 KB |
testcase_19 | AC | 19 ms
5,248 KB |
testcase_20 | AC | 94 ms
12,672 KB |
testcase_21 | AC | 195 ms
23,424 KB |
testcase_22 | AC | 271 ms
32,288 KB |
testcase_23 | AC | 24 ms
6,816 KB |
testcase_24 | AC | 111 ms
14,208 KB |
testcase_25 | AC | 204 ms
24,704 KB |
testcase_26 | AC | 53 ms
8,064 KB |
testcase_27 | AC | 199 ms
23,680 KB |
testcase_28 | AC | 100 ms
13,636 KB |
testcase_29 | AC | 240 ms
28,712 KB |
testcase_30 | AC | 24 ms
5,248 KB |
testcase_31 | AC | 156 ms
19,456 KB |
testcase_32 | AC | 140 ms
17,152 KB |
testcase_33 | AC | 278 ms
31,712 KB |
testcase_34 | AC | 283 ms
32,096 KB |
testcase_35 | AC | 284 ms
31,580 KB |
testcase_36 | AC | 280 ms
31,200 KB |
testcase_37 | AC | 278 ms
32,860 KB |
ソースコード
#![allow(non_snake_case)] #![allow(unused_imports)] #![allow(unused_macros)] #![allow(clippy::needless_range_loop)] #![allow(clippy::comparison_chain)] #![allow(clippy::nonminimal_bool)] #![allow(clippy::neg_multiply)] #![allow(dead_code)] use std::cmp::Reverse; use std::collections::{BTreeMap, BTreeSet, BinaryHeap, VecDeque}; #[derive(Default)] struct Solver {} impl Solver { fn solve(&mut self) { input! { N: usize, M: usize, mut W: usize, A: [usize; N], B: [usize; M], C: [usize; M] } let mut D = vec![]; for &a in A.iter() { D.push((a, 1)); } for (&b, &c) in B.iter().zip(C.iter()) { D.push((c, b)); } D.sort(); D.reverse(); D.sort_by(|(a, b), (c, d)| (b * c).cmp(&(a * d))); let mut ans = 0; for &(v, w) in D.iter() { if w <= W { ans += v; W -= w; } } println!("{}", ans); } } fn main() { std::thread::Builder::new() .stack_size(128 * 1024 * 1024) .spawn(|| Solver::default().solve()) .unwrap() .join() .unwrap(); } #[macro_export] macro_rules! input { () => {}; (mut $var:ident: $t:tt, $($rest:tt)*) => { let mut $var = __input_inner!($t); input!($($rest)*) }; ($var:ident: $t:tt, $($rest:tt)*) => { let $var = __input_inner!($t); input!($($rest)*) }; (mut $var:ident: $t:tt) => { let mut $var = __input_inner!($t); }; ($var:ident: $t:tt) => { let $var = __input_inner!($t); }; } #[macro_export] macro_rules! __input_inner { (($($t:tt),*)) => { ($(__input_inner!($t)),*) }; ([$t:tt; $n:expr]) => { (0..$n).map(|_| __input_inner!($t)).collect::<Vec<_>>() }; ([$t:tt]) => {{ let n = __input_inner!(usize); (0..n).map(|_| __input_inner!($t)).collect::<Vec<_>>() }}; (chars) => { __input_inner!(String).chars().collect::<Vec<_>>() }; (bytes) => { __input_inner!(String).into_bytes() }; (usize1) => { __input_inner!(usize) - 1 }; ($t:ty) => { $crate::read::<$t>() }; } #[macro_export] macro_rules! println { () => { $crate::write(|w| { use std::io::Write; std::writeln!(w).unwrap() }) }; ($($arg:tt)*) => { $crate::write(|w| { use std::io::Write; std::writeln!(w, $($arg)*).unwrap() }) }; } #[macro_export] macro_rules! print { ($($arg:tt)*) => { $crate::write(|w| { use std::io::Write; std::write!(w, $($arg)*).unwrap() }) }; } #[macro_export] macro_rules! flush { () => { $crate::write(|w| { use std::io::Write; w.flush().unwrap() }) }; } pub fn read<T>() -> T where T: std::str::FromStr, T::Err: std::fmt::Debug, { use std::cell::RefCell; use std::io::*; thread_local! { pub static STDIN: RefCell<StdinLock<'static>> = RefCell::new(stdin().lock()); } STDIN.with(|r| { let mut r = r.borrow_mut(); let mut s = vec![]; loop { let buf = r.fill_buf().unwrap(); if buf.is_empty() { break; } if let Some(i) = buf.iter().position(u8::is_ascii_whitespace) { s.extend_from_slice(&buf[..i]); r.consume(i + 1); if !s.is_empty() { break; } } else { s.extend_from_slice(buf); let n = buf.len(); r.consume(n); } } std::str::from_utf8(&s).unwrap().parse().unwrap() }) } pub fn write<F>(f: F) where F: FnOnce(&mut std::io::BufWriter<std::io::StdoutLock>), { use std::cell::RefCell; use std::io::*; thread_local! { pub static STDOUT: RefCell<BufWriter<StdoutLock<'static>>> = RefCell::new(BufWriter::new(stdout().lock())); } STDOUT.with(|w| f(&mut w.borrow_mut())) } // trait Bound<T> { // fn lower_bound(&self, x: &T) -> usize; // fn upper_bound(&self, x: &T) -> usize; // } // impl<T: PartialOrd> Bound<T> for [T] { // fn lower_bound(&self, x: &T) -> usize { // let (mut low, mut high) = (0, self.len()); // while low + 1 < high { // let mid = (low + high) / 2; // if self[mid] < *x { // low = mid; // } else { // high = mid; // } // } // if self[low] < *x { // low + 1 // } else { // low // } // } // fn upper_bound(&self, x: &T) -> usize { // let (mut low, mut high) = (0, self.len()); // while low + 1 < high { // let mid = (low + high) / 2; // if self[mid] <= *x { // low = mid; // } else { // high = mid; // } // } // if self[low] <= *x { // low + 1 // } else { // low // } // } // }