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 C++ (GCC 9.2.1) (judge verdict: Wrong Answer)


#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<map>
#include<random>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include <queue>
#include<boost/multiprecision/cpp_int.hpp>


using namespace std;
using namespace boost::multiprecision;

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldb = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney, tree, chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun

#define REP(i,a,b) for(ll i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIF(v, n) printf("%."#n"f\n", v)
#define PRIY PRI("Yes")
#define PRIN PRI("No")
template<typename A, typename B>
void mins(A & a, const B & b) { a = min(a, (A)b); };
template<typename A, typename B>
void maxs(A & a, const B & b) { a = max(a, (A)b); };


vector<pair<ll, ll>> fact(ll x) {
	vector<pair<ll, ll>> ret;
	ll tmp = x;
	for (ll i = 2; i * i <= x; ++i) {
		if (tmp % i == 0) {
			ret.push_back(pair<ll, ll>{i, 0});
			do {
				ret.back().second++;
				tmp /= i;
			} while (tmp % i == 0);
		}
	}
	if (tmp != 1) ret.push_back(pair<ll, ll>{tmp, 1});
	return ret;
}

ll pw(ll r, ll n) {
	ll tmp = r;
	ll ans = 1;
	while (n > 0) {
		if ((n & 1) > 0) ans *= tmp;
		tmp *= tmp;
		n >>= 1;
	}
	return ans;
}

struct frac_table {
	ll N;
	vector<unordered_map<ll, ll>> tbl;
	frac_table(ll N) : N(N), tbl(N+1) {
		REP(i, 2, N + 1) {
			tbl[i] = tbl[i - 1];
			auto ret = fact(i);
			for (auto p : ret) {
				if (tbl[i].count(p.first) == 0) tbl[i].insert({ p.first,0 });
				tbl[i][p.first] += p.second;
			}
		}
	}
	ll com(ll a, ll b) {
		if (a < b)return 0;
		unordered_map<ll, ll> mp = tbl[a];
		for (auto p : tbl[b]) mp[p.first]-= p.second;
		for (auto p : tbl[a - b]) mp[p.first]-=p.second;
		ll ans = 1;
		for (auto p : mp) ans *= pw(p.first, p.second);
		return ans;
	}
};

int main() {
	double eps = 1e-7;
	frac_table tbl{ 50 };
	ll N, A, B; cin >> N >> A >> B;
	vector<ll> V(N); REP(i, 0, N) cin >> V[i];
	sort(V.begin(), V.end());
	vector<ll> avgmax_index;
	double avgmax = 0;
	REP(k, A, B + 1) {
		ll sum = 0;
		REP(i, 0, k) sum += V[N - 1 - i];
		double avg = (double)sum / k;
		if (avg > avgmax + eps) {
			avgmax = avg;
			avgmax_index.clear();
			avgmax_index.push_back(k);
		}
		else if (abs(avg - avgmax) < eps) {
			avgmax_index.push_back(k);
		}
	}
	ll cnt = 0;
	for (int k : avgmax_index) {
		ll x = V[N - k];
		int x_num = distance(lower_bound(V.begin(), V.end(), x), upper_bound(V.begin(), V.end(), x));
		int used_num = 0;
		int ind = N - k;
		while (ind < V.size() && V[ind] == x) {
			++ind;
			++used_num;
		}
		cnt += tbl.com(x_num, used_num);
	}
	PRIF(avgmax, 8);
	PRI(cnt);
	return 0;
}