#![allow(non_snake_case, unused_imports)] use std::collections::{BinaryHeap, HashMap, HashSet}; use proconio::{input, marker::Usize1, marker::Chars}; use itertools::Itertools; #[allow(unused_macros)] macro_rules! d { ( $( $x:expr ),* $(,)? ) => { eprintln!( concat!( $( stringify!($x), "={:?} " ),* ), $( $x ),* ); }; } #[allow(dead_code)] fn yn(b: bool) -> &'static str { if b { "Yes" } else { "No" } } fn median(a: &[f64]) -> f64 { if a.len() % 2 == 1 { a[a.len() / 2] } else { let s = a.len() / 2; (a[s-1] + a[s]) / 2.0 } } fn main() { input! { N: usize, A: [i64; N], } let v = A.iter() .sorted() .map(|&x| x as f64) .collect_vec(); let k = N / 2; let q1 = median(&v[..k]); let q2 = median(&v); let q3 = median(&v[v.len()-k..]); let iqr = q3 - q1; let cnt = v.iter() .filter(|&&x| { if x < q1 - 1.5 * iqr { return true } if x > q3 + 1.5 * iqr { return true } false }) .count(); println!("{} {} {} {}", q1, q2, q3, cnt); }