Language: C++

#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll LLINF = 1LL<<60;
const int INTINF = 1<<30;
const int MOD = 1000000007;

void add(long long &a, long long b) {
  a += b;
  if (a >= MOD) a -= MOD;
}

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};


const int MAX = 51000000000000000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, A, B; cin >> N >> A >> B;
    vector<long long> v(N);
    for (int i = 0; i < N; ++i) cin >> v[i];
    sort(v.begin(), v.end(), greater<long long>());

    // 最大値
    long long sum = 0;
    COMinit();
    for (int i = 0; i < A; ++i) sum += v[i];
    double ave = (double)(sum) / A;

    // 小さいやつの個数
    long long res = 0;
    int num = 0;
    for (int i = 0; i < N; ++i) if (v[i] == v[A-1]) ++num;
    if (v[0] == v[A-1]) {
        for (int j = A; j <= B; ++j) {
            res += COM(num, j);
        }
    }
    else {
        int a = 0;
        for (int i = 0; i < A; ++i) if (v[i] == v[A-1]) ++a;
        res = COM(num, a);
    }
    cout << fixed << setprecision(10) << ave << endl;
    cout << res << endl;
}


Compiler output:
a.cc:24:17: warning: overflow in conversion from 'long int' to 'int' changes value from '51000000000000000' to '-745832448' [-Woverflow]
   24 | const int MAX = 51000000000000000;
      |                 ^~~~~~~~~~~~~~~~~
a.cc:26:18: error: narrowing conversion of '-745832448' from 'int' to 'long unsigned int' [-Wnarrowing]
   26 | long long fac[MAX], finv[MAX], inv[MAX];
      |                  ^
a.cc:26:15: error: size '-745832448' of array 'fac' is negative
   26 | long long fac[MAX], finv[MAX], inv[MAX];
      |               ^~~
a.cc:26:29: error: narrowing conversion of '-745832448' from 'int' to 'long unsigned int' [-Wnarrowing]
   26 | long long fac[MAX], finv[MAX], inv[MAX];
      |                             ^
a.cc:26:26: error: size '-745832448' of array 'finv' is negative
   26 | long long fac[MAX], finv[MAX], inv[MAX];
      |                          ^~~
a.cc:26:39: error: narrowing conversion of '-745832448' from 'int' to 'long unsigned int' [-Wnarrowing]
   26 | long long fac[MAX], finv[MAX], inv[MAX];
      |                                       ^
a.cc:26:36: error: size '-745832448' of array 'inv' is negative
   26 | long long fac[MAX], finv[MAX], inv[MAX];
      |                                    ^~~