macro_rules! get { ($t:ty) => { { let mut line: String = String::new(); std::io::stdin().read_line(&mut line).unwrap(); line.trim().parse::<$t>().unwrap() } }; ($($t:ty),*) => { { let mut line: String = String::new(); std::io::stdin().read_line(&mut line).unwrap(); let mut iter = line.split_whitespace(); ( $(iter.next().unwrap().parse::<$t>().unwrap(),)* ) } }; ($t:ty; $n:expr) => { (0..$n).map(|_| get!($t) ).collect::>() }; ($($t:ty),*; $n:expr) => { (0..$n).map(|_| get!($($t),*) ).collect::>() }; ($t:ty ;;) => { { let mut line: String = String::new(); std::io::stdin().read_line(&mut line).unwrap(); line.split_whitespace() .map(|t| t.parse::<$t>().unwrap()) .collect::>() } }; ($t:ty ;; $n:expr) => { (0..$n).map(|_| get!($t ;;)).collect::>() }; } fn q_sort(nums: Vec) -> Vec { if nums.len() <= 1 { nums } else { let pivot = nums[0]; let mut left: Vec = Vec::new(); let mut right: Vec = Vec::new(); for num in (nums[1..]).into_iter() { if *num <= pivot { left.push(*num) } else { right.push(*num) } } let mut sorted_l = q_sort(left); let mut sorted_r = q_sort(right); let mut res = Vec::new(); res.append(&mut sorted_l); res.push(pivot); res.append(&mut sorted_r); res } } fn get_median(nums: Vec) -> f32 { let len = nums.len(); if len % 2 == 0 { (nums[len / 2 - 1] + nums[len / 2]) as f32 / 2.0 } else { nums[len / 2] as f32 } } fn main() { let _len = get!(i32); let data: Vec = get!(i32;;); println!("{}", get_median(q_sort(data))) }