pub use __cargo_equip::prelude::*; use chminmax::{chmax, chmin}; use div::div_ceil; #[allow(unused_imports)] use proconio::{ input, marker::{Bytes, Chars, Usize1}, }; const M: i64 = 3010; fn main() { input! { na: usize, nb: usize, nc: usize, mut a: [i64; na], mut b: [i64; nb], mut c: [i64; nc], } a.sort_unstable_by_key(|&x| -x); b.sort_unstable_by_key(|&x| -x); c.sort_unstable_by_key(|&x| -x); let mut cnt = vec![0; (M * 2) as usize]; let mut sum = vec![0; (M * 2) as usize]; for &x in &a { cnt[(x + M) as usize] += 1; sum[(x + M) as usize] += x; } for i in (1..cnt.len()).rev() { cnt[i - 1] += cnt[i]; sum[i - 1] += sum[i]; } let mut cand_b = vec![(0, 0)]; let mut sum_b = 0; for cnt_b in 1..=nb { sum_b += b[cnt_b - 1]; if cnt_b < nb && b[cnt_b - 1] == b[cnt_b] { continue; } cand_b.push((cnt_b, sum_b)); } let mut cand_c = vec![(0, 0)]; let mut sum_c = 0; for cnt_c in 1..=nc { sum_c += c[cnt_c - 1]; if cnt_c < nc && c[cnt_c - 1] == c[cnt_c] { continue; } cand_c.push((cnt_c, sum_c)); } let mut res = 0; for &(cnt_b, sum_b) in &cand_b { for &(cnt_c, sum_c) in &cand_c { if cnt_b == 0 { chmax!(res, sum_c * na as i64); continue; } let mut x = div_ceil(-sum_c, cnt_b as i64); chmax!(x, -3000); let mut x = (x + M) as usize; chmin!(x, cnt.len() - 1); let cnt_a = cnt[x]; let sum_a = sum[x]; chmax!( res, sum_a * cnt_b as i64 + sum_b * cnt_c as i64 + sum_c * cnt_a as i64, ); } } 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` /// - `div 0.1.0 (path+█████████████████████████████████████████████)` published in **missing** licensed under `CC0-1.0` as `crate::__cargo_equip::crates::div` #[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(crate::__cargo_equip_macro_def_chminmax_chmax!{$($tt)*})}} pub mod div {use std::ops::{Add,BitXor,Div,Rem,Sub};pub trait Zero{fn zero()->Self;fn is_zero(&self)->bool;}pub trait One{fn one()->Self;fn is_one(&self)->bool;}macro_rules!impl_zero_one{($($t:ty)*)=>{$(impl$crate::__cargo_equip::crates::div::Zero for$t{fn zero()->Self{0}fn is_zero(&self)->bool{*self==0}}impl$crate::__cargo_equip::crates::div::One for$t{fn one()->Self{1}fn is_one(&self)->bool{*self==1}})*};}impl_zero_one!(usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128);pub fn div_ceil(a:T,b:T)->T where T:Copy+Zero+One+Add+Div+Rem+BitXor+PartialOrd,{let zero=T::zero();let one=T::one();a/b+if a^b>=zero&&a%b!=zero{one}else{zero}}pub fn div_floor(a:T,b:T)->T where T:Copy+Zero+One+Sub+Div+Rem+BitXor+PartialOrd,{let zero=T::zero();let one=T::one();a/b-if a^b