Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
using ll = long long;
constexpr long long INF = 1LL << 62;
constexpr int MOD = 1e9 + 7;

double dp[55][55];
long long table[55][55];

void make_pascal() {
    for(int i = 0; i < 55; ++i) {
        table[i][0] = 1;
        for (int j = 1; j < i; j++) {
            table[i][j] = table[i-1][j-1] + table[i-1][j];
        }
        table[i][i] = 1;
    }
}

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int N,A,B; cin >> N >> A >> B;
    double v[50]; REP(i,N) cin >> v[i];
    make_pascal();

    REP(i,N) {
        REP(j,N){
            double next = (dp[i][j] + v[i]) / (j+1);
            chmax(dp[i+1][j+1], next);
            chmax(dp[i+1][j  ], dp[i][j]);
        }
    }

    // count
    sort(v, v + N, greater<double>());
    int num = 0, pos = 0;
    for(int i=0;i<N;++i){
        if(v[i] == v[A-1]) {
            ++num;
            if(i < A) ++pos;
        }
    }

    ll cnt = 0LL;
    if(pos == A){
        for(pos = A; pos <= B; ++pos) cnt += table[num][pos];
    } else {
        cnt += table[num][pos];
    }

    double ans = 0.0;
    REP(i,N+1) if(A<=i && i<=B) chmax(ans, dp[N][i]);
    cout << fixed << setprecision(10) << ans << '\n';
    cout << cnt << '\n';
    return 0;
}
// build O(n), query O(logn)
struct SegmentTree {
    vector<int> data;
    int n;
    SegmentTree(int n_) {
        for(n = 1; n < n_; n *= 2);
        data.assign(n*2 - 1, INT_MAX);
    }

    void update(int i,int x){
        i += n - 1;
        data[i] = x;
        while(i){
            i = (i-1) / 2;
            data[i] = min(data[i*2 + 1], data[i*2 + 2]);
        }
    }
    // query for [a,b)
    int query(int a,int b,int i,int l,int r){
        if(b<=l || r<=a) return INT_MAX;
        if(a<=l && r<=b) return data[i];
        int vl = query(a, b, i*2+1, l, (l+r)/2);
        int vr = query(a, b, i*2+2, (l+r)/2, r);
        return min(vl,vr);
    }
    int query(int a,int b){
        return query(a, b, 0, 0, n);
    }
}

Compiler output:
a.cc:95:2: error: expected ';' after struct definition
   95 | }
      |  ^
      |  ;
a.cc: In constructor 'SegmentTree::SegmentTree(int)':
a.cc:73:30: error: 'INT_MAX' was not declared in this scope
   73 |         data.assign(n*2 - 1, INT_MAX);
      |                              ^~~~~~~
a.cc:8:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    7 | #include <iomanip>
  +++ |+#include <climits>
    8 | using namespace std;
a.cc: In member function 'int SegmentTree::query(int, int, int, int, int)':
a.cc:86:33: error: 'INT_MAX' was not declared in this scope
   86 |         if(b<=l || r<=a) return INT_MAX;
      |                                 ^~~~~~~
a.cc:86:33: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'