Problem:
Score : 500 points

Problem Statement

You are going to eat X red apples and Y green apples.

You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C.

Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively.

From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible.

Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.

Constraints

1 \leq X \leq A \leq 10^5

1 \leq Y \leq B \leq 10^5

1 \leq C \leq 10^5

1 \leq p_i \leq 10^9

1 \leq q_i \leq 10^9

1 \leq r_i \leq 10^9

All values in input are integers.

Input

Input is given from Standard Input in the following format:

X Y A B C
p_1 p_2 ... p_A
q_1 q_2 ... q_B
r_1 r_2 ... r_C

Output

Print the maximum possible sum of the deliciousness of the eaten apples.

Sample Input 1

1 2 2 2 1
2 4
5 1
3

Sample Output 1

12

The maximum possible sum of the deliciousness of the eaten apples can be achieved as follows:

Eat the 2-nd red apple.

Eat the 1-st green apple.

Paint the 1-st colorless apple green and eat it.

Sample Input 2

2 2 2 2 2
8 6
9 1
2 1

Sample Output 2

25

Sample Input 3

2 2 4 4 4
11 12 13 14
21 22 23 24
1 2 3 4

Sample Output 3

74

Solution in Rust (1.15.1) (judge verdict: Wrong Answer)

#![allow(unused_imports)]
#![allow(non_snake_case, unused)]

use std::cmp::*;
use std::collections::*;
use std::ops::*;

macro_rules! eprint {
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = write!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! eprintln {
	() => { eprintln!(""); };
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = writeln!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! dbg {
	($v:expr) => {{
		let val = $v;
		eprintln!("[{}:{}] {} = {:?}", file!(), line!(), stringify!($v), val);
		val
	}}
}

macro_rules! mat {
	($($e:expr),*) => { Vec::from(vec![$($e),*]) };
	($($e:expr,)*) => { Vec::from(vec![$($e),*]) };
	($e:expr; $d:expr) => { Vec::from(vec![$e; $d]) };
	($e:expr; $d:expr $(; $ds:expr)+) => { Vec::from(vec![mat![$e $(; $ds)*]; $d]) };
}

macro_rules! ok {
	($a:ident$([$i:expr])*.$f:ident()$(@$t:ident)*) => {
		$a$([$i])*.$f($($t),*)
	};
	($a:ident$([$i:expr])*.$f:ident($e:expr$(,$es:expr)*)$(@$t:ident)*) => { {
		let t = $e;
		ok!($a$([$i])*.$f($($es),*)$(@$t)*@t)
	} };
}

pub fn readln() -> String {
	let mut line = String::new();
	::std::io::stdin().read_line(&mut line).unwrap_or_else(|e| panic!("{}", e));
	line
}

macro_rules! read {
	($($t:tt),*; $n:expr) => {{
		let stdin = ::std::io::stdin();
		let ret = ::std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
			let line = line.unwrap();
			let mut it = line.split_whitespace();
			_read!(it; $($t),*)
		}).collect::<Vec<_>>();
		ret
	}};
	($($t:tt),*) => {{
		let line = readln();
		let mut it = line.split_whitespace();
		_read!(it; $($t),*)
	}};
}

macro_rules! _read {
	($it:ident; [char]) => {
		_read!($it; String).chars().collect::<Vec<_>>()
	};
	($it:ident; [u8]) => {
		Vec::from(_read!($it; String).into_bytes())
	};
	($it:ident; usize1) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1
	};
	($it:ident; [usize1]) => {
		$it.map(|s| s.parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::<Vec<_>>()
	};
	($it:ident; [$t:ty]) => {
		$it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
	};
	($it:ident; $t:ty) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
	};
	($it:ident; $($t:tt),+) => {
		($(_read!($it; $t)),*)
	};
}

pub fn main() {
	let _ = ::std::thread::Builder::new().name("run".to_string()).stack_size(32 * 1024 * 1024).spawn(run).unwrap().join();
}

const MOD: usize = 1_000_000_007;
const INF: i64 = std::i64::MAX/2;

pub trait SetMinMax {
	fn setmin(&mut self, v: Self) -> bool;
	fn setmax(&mut self, v: Self) -> bool;
}
impl<T> SetMinMax for T where T: PartialOrd {
	fn setmin(&mut self, v: T) -> bool {
		*self > v && { *self = v; true }
	}
	fn setmax(&mut self, v: T) -> bool {
		*self < v && { *self = v; true }
	}
}

fn solve() {
	let (x,y,a,b,c) = read!(usize,usize,usize,usize,usize);
	let mut p = read!([i64]);
	let mut q = read!([i64]);
	let mut r = read!([i64]);
	p.sort_by(|a, b| b.partial_cmp(a).unwrap());
	q.sort_by(|a, b| b.partial_cmp(a).unwrap());
	r.sort_by(|a, b| b.partial_cmp(a).unwrap());
	let mut cp = vec![0;p.len()+1];	
	let mut cq = vec![0;q.len()+1];	
	let mut cr = vec![0;r.len()+1];	
	for i in 0..p.len() {
		cp[i+1] = cp[i] + p[i];
	}
	for i in 0..q.len() {
		cq[i+1] = cq[i] + q[i];
	}
	for i in 0..r.len() {
		cr[i+1] = cr[i] + r[i];
	}
	let mut ans = 0;
	for i in 0..(x+y+1) {
		if i>(p.len()+q.len()){
			break;
		}
		let mut left = -1;
		let mut right = p.len() as i64;
		while right-left>10 {
			let mut lval = 0;
			let mut rval = 0;
			let pl = (left*2+right)/3;
			let ql = i as i64 - (pl+1) - 1;
			if ql < 0  || ql >= q.len() as i64 || pl >= x as i64 || ql >= y as i64{
				if ql!=-1 || (ql >= q.len() as i64 || pl >= x as i64 || ql >= y as i64) {
					lval = -1;
				}
			}
			if lval!=-1 {
				let lv = cp[(pl + 1) as usize];
				let rv = cq[(ql + 1) as usize];
				lval = lv + rv;
			}
			let pr = (left+right*2)/3;
			let qr = i as i64 - (pr+1) - 1;
			if qr < 0  || qr >= q.len() as i64 || pr >= x as i64 || qr >= y as i64{
				if qr!=-1  || (qr >= q.len() as i64 || pr >= x as i64 || qr >= y as i64) {
					rval = -1;
				}
			}
			if rval!=-1 {
				let lv = cp[(pr+1) as usize];
				let rv = cq[(qr+1) as usize];
				rval = lv + rv;
			}
			// if lval==-1&&rval==-1 {
			// 	break;
			// }
			// else if rval==-1 {
			// 	right = pr;
			// 	continue;
			// }
			// else if lval==-1 {
			// 	left = ql;
			// 	continue;
			// }

			if lval>=rval-1 {
				right = pr;
			}
			else {
				left = pl;
			}
			
			// println!("{} {}", left, right);
		}
		let mut target = -2;
		let mut sum = 0;
		for j in left..(right+1){
			if j<0 || j>=p.len() as i64 || j >= x as i64{
				if j!=-1  || (j>=p.len() as i64 || j >= x as i64)  {
					continue;
				}
			}
			let mut lval = 0;
			let pl = j;
			let ql = i as i64 - (pl+1) - 1;
			if ql < 0  || ql >= q.len() as i64 || pl >= x as i64 || ql >= y as i64{
				if ql!=-1 || (ql >= q.len() as i64 || pl >= x as i64 || ql >= y as i64) {
					continue;
				}
			}
			let lv = cp[(pl+1) as usize];
			let rv = cq[(ql+1) as usize];
			if lv+rv>=sum {
				sum = lv+rv;
				target = j;
			}
		}
		if target==-2 {
			continue;
		}
		// println!("{} {}", left, right);
		// println!("{} {} {}", i, target, sum);
		let res = x+y-i;
		if res>r.len() {
			continue;
		}
		sum += cr[res];
		ans = max(ans, sum);
	}
	println!("{}", ans);
}

fn run() {
    solve();
}