Language: C++

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 1
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif


//改造
typedef long long int ll;
using namespace std;




//ここから編集する
#define MAX_PAS 50 //最大の第一引数
ll pascal[MAX_PAS + 1][MAX_PAS + 1];

void calcPascal() {
    REP(i, 1, MAX_PAS + 1) {
        pascal[i][i] = 1;
        pascal[i][0] = 1;
    }
    REP(i, 1, MAX_PAS + 1) {
        REP(j, 1, i) {
            if (pascal[i][j] == 0)pascal[i][j] = pascal[i - 1][j - 1] + pascal[i - 1][j];
        }
    }
}

ll nCr(int n,int r){
    if(pascal[n][r] != 0) return pascal[n][r];
    if(n == 0 || n == r) return 1;
    return nCr(n-1,r-1) + nCr(n-1,r);
}


int main() {
    calcPascal();
    int A;
    int B;
    int N;
    ll selects = 0;
    cin >> N >> A >> B;
    vector<ll> v(N);
    REP(i, 0, N) {
        cin >> v[i];
    }

    sort(v.begin(), v.end(), greater<ll>());


    double ave;
    while (v[A - 1] != v[B - 1]) {
        B--;
    }

    if (v[A - 1] == v[0]) {
        ave = (double) v[0];
        REP(i, A, B + 1) {
//            selects += pascal[B][i];
            selects += nCr[B][i];
        }
    } else {
        ll sum_v = 0;
        int M = 0;
        REP(i, 0, A) {
            sum_v += v[i];
        }
        REP(i, 0, N) {
            if (v[i] == v[A - 1]) {
                M++;
            }
        }
        ave = (double) sum_v / A;
        int begin = A - 1;
        while (v[begin] == v[A - 1] && begin >= 0) {
            begin--;
        }
//        selects = pascal[M][A - 1 - begin];
        selects = nCr(M,A-1-begin);

    }

    cout << fixed << setprecision(7) << ave << endl;


    cout << selects << endl;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:109:29: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  109 |             selects += nCr[B][i];
      |                             ^
a.cc:109:32: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  109 |             selects += nCr[B][i];
      |                                ^
a.cc:109:21: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  109 |             selects += nCr[B][i];
      |             ~~~~~~~~^~~~~~~~~~~~
a.cc:109:21: error: invalid conversion from 'll (*)(int, int)' {aka 'long long int (*)(int, int)'} to 'll' {aka 'long long int'} [-fpermissive]
  109 |             selects += nCr[B][i];
      |             ~~~~~~~~^~~~~~~~~~~~
      |                     |
      |                     ll (*)(int, int) {aka long long int (*)(int, int)}