#[allow(unused_imports)] use std::cmp::{max, min, Ordering, Reverse}; #[allow(unused_imports)] use std::collections::{HashMap, HashSet}; mod util { use std::io::stdin; use std::str::FromStr; use std::fmt::Debug; #[allow(dead_code)] pub fn line() -> String { let mut line: String = String::new(); stdin().read_line(&mut line).unwrap(); line.trim().to_string() } #[allow(dead_code)] pub fn get() -> T where ::Err: Debug, { let mut line: String = String::new(); stdin().read_line(&mut line).unwrap(); line.trim().parse().unwrap() } #[allow(dead_code)] pub fn gets() -> Vec where ::Err: Debug, { let mut line: String = String::new(); stdin().read_line(&mut line).unwrap(); line.split_whitespace() .map(|t| t.parse().unwrap()) .collect() } #[allow(dead_code)] pub fn get2() -> (T, U) where ::Err: Debug, ::Err: Debug, { let mut line: String = String::new(); stdin().read_line(&mut line).unwrap(); let mut iter = line.split_whitespace(); ( iter.next().unwrap().parse().unwrap(), iter.next().unwrap().parse().unwrap(), ) } #[allow(dead_code)] pub fn get3() -> (S, T, U) where ::Err: Debug, ::Err: Debug, ::Err: Debug, { let mut line: String = String::new(); stdin().read_line(&mut line).unwrap(); let mut iter = line.split_whitespace(); ( iter.next().unwrap().parse().unwrap(), iter.next().unwrap().parse().unwrap(), iter.next().unwrap().parse().unwrap(), ) } } // std::cmp::Reverse doesn't have Clone. #[derive(Eq, PartialEq, Clone)] struct Rev(pub T); impl PartialOrd for Rev { fn partial_cmp(&self, other: &Rev) -> Option { other.0.partial_cmp(&self.0) } } impl Ord for Rev { fn cmp(&self, other: &Rev) -> Ordering { other.0.cmp(&self.0) } } #[allow(unused_macros)] macro_rules! debug { ($x: expr) => { println!("{}: {:?}", stringify!($x), $x) } } struct BIT { buf: Vec, } impl BIT { fn new(n: usize) -> BIT { BIT { buf: vec![0; n + 1] } } fn sum(&self, i: usize) -> usize { let mut i = i; let mut s = 0; while i > 0 { s += self.buf[i]; i = i & (i - 1); } s } fn add(&mut self, i: usize, x: usize) { let mut i = i as i64; while i < self.buf.len() as i64 { self.buf[i as usize] += x; i += i & -i; } } } fn score(s: i64, rank: i64) -> i64 { let rhs = 50.0 * s as f64 / (0.8 + 0.2 * rank as f64); 50 * s + rhs as i64 } fn main() { let (n, s, id): (usize, i64, usize) = util::get3(); let mut a: Vec = util::gets(); let me = a[id] + 100 * s; a.remove(id); a.sort_by_key(|&x| Reverse(x)); let m = n - 1; let scores: Vec = (1..m + 1).rev().map(|i| score(s, i as i64)).collect(); let ans = a.iter() .enumerate() .map(|(k, &x)| { let rank = match scores.binary_search(&(me - x + 1)) { Ok(i) => Some(i), Err(i) => if i == scores.len() { None } else { Some(i) }, }; rank.map(|i| if k > i { 0.0 } else { (i - k) as f64 / (m - k) as f64 }).unwrap_or(1.0) }) .fold(1.0, |a, b| a * b); println!("{}", ans); }