Problem:
Score : 400 points

Problem Statement

You are given N items.

The value of the i-th item (1 \leq i \leq N) is v_i.

Your have to select at least A and at most B of these items.

Under this condition, find the maximum possible arithmetic mean of the values of selected items.

Additionally, find the number of ways to select items so that the mean of the values of selected items is maximized.

Constraints

1 \leq N \leq 50

1 \leq A,B \leq N

1 \leq v_i \leq 10^{15}

Each v_i is an integer.

Input

The input is given from Standard Input in the following format:

N A B
v_1
v_2
...
v_N

Output

Print two lines.

The first line should contain the maximum possible arithmetic mean of the values of selected items. The output should be considered correct if the absolute or relative error is at most 10^{-6}.

The second line should contain the number of ways to select items so that the mean of the values of selected items is maximized.

Sample Input 1

5 2 2
1 2 3 4 5

Sample Output 1

4.500000
1

The mean of the values of selected items will be maximized when selecting the fourth and fifth items. Hence, the first line of the output should contain 4.5.

There is no other way to select items so that the mean of the values will be 4.5, and thus the second line of the output should contain 1.

Sample Input 2

4 2 3
10 20 10 10

Sample Output 2

15.000000
3

There can be multiple ways to select items so that the mean of the values will be maximized.

Sample Input 3

5 1 5
1000000000000000 999999999999999 999999999999998 999999999999997 999999999999996

Sample Output 3

1000000000000000.000000
1

Solution in Rust (1.15.1) (judge verdict: Accepted)

#[test]
fn test_solve() {
    assert_eq!(solve("5 2 2\n1 2 3 4 5\n"), "4.500000\n1\n");
    assert_eq!(solve("4 2 3\n10 20 10 10\n"), "15.000000\n3\n");
    assert_eq!(solve("5 1 5\n1000000000000000 999999999999999 999999999999998 999999999999997 999999999999996\n"), "1000000000000000.000000\n1\n");
    assert_eq!(solve("50 1 50\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n"), "1.000000\n1125899906842623\n");
}

fn solve(src: &str) -> String {
    let mut sc = Scanner::from_str(src);

    let mut comb = vec![vec![1]];
    for n in 1..51 {
        comb.push(Vec::new());
        comb[n].push(1);
        for r in 1..n {
            let tmp = comb[n - 1][r - 1] + comb[n - 1][r];
            comb[n].push(tmp);
        }
        comb[n].push(1);
    }

    let n: usize = sc.read();
    let a: usize = sc.read();
    let b: usize = sc.read();
    let mut v: Vec<u64> = (0..n).map(|_| sc.read()).collect();
    v.sort_by(|a, b| b.cmp(a));
    let s = v.iter().take(a).sum::<u64>() as f64;
    let av = s / a as f64;
    let nc: usize = if v[0] == v[a - 1] {
        let len = 1 + bis_usize(0, n, |i| v[i] == v[0]);
        (a..b + 1)
            .map(|a| if len >= a { comb[len][a] } else { 0 })
            .sum()
    } else {
        let l1 = a - bis_usize(a - 1, 0, |i| v[i] == v[a - 1]);
        let l2 = bis_usize(a - 1, n, |i| v[i] == v[a - 1]) + l1 + 1 - a;
        comb[l2][l1]
    };

    format!("{:.6}\n{}\n", av, nc)
}

fn bis_usize<P>(t: usize, f: usize, eval: P) -> usize
where
    P: Fn(usize) -> bool,
{
    if t > f {
        if t - f == 1 {
            return t;
        }
    } else if f - t == 1 {
        return t;
    }
    let m = (t + f) >> 1;
    if eval(m) {
        bis_usize(m, f, eval)
    } else {
        bis_usize(t, m, eval)
    }
}

fn main() {
    let mut buf = String::new();
    use std::io;
    use std::io::{Read, Write};
    io::stdin().read_to_string(&mut buf).unwrap();
    io::stdout().write_all(solve(&buf).as_bytes()).unwrap();
}

struct Scanner<'a>(std::str::SplitWhitespace<'a>);
impl<'a> Scanner<'a> {
    fn from_str(src: &str) -> Scanner {
        Scanner(src.split_whitespace())
    }
    fn get(&mut self) -> &str {
        self.0.next().unwrap()
    }
    fn read<T: std::str::FromStr>(&mut self) -> T {
        self.get().parse().ok().unwrap()
    }
}