public void Run() { { var line = Input.ReadIntArray(); N = line[0]; A = line[1]; B = line[2]; } V = Input.ReadLongArray(); Array.Sort(V); Array.Reverse(V); var comb = new PascalCombination(100); comb.Run(); long val = V[A - 1]; int up = 0; int same = 0; for (int i = 0; i < N; i++) { if (V[i] > val) { up++; } if (V[i] == val) { same++; } } { long retc = 0; int mn = A - up; int mx; if (up == 0) { mx = Math.Min(same, B - up); } else { mx = mn; } for (int j = mn; j <= mx; j++) { Console.Error.WriteLine($"{same} {j}"); retc += comb.Combination(same, j); } double avg = V.Take(A).Sum() * 1.0 / A; Console.WriteLine(avg); Console.WriteLine(retc); } }
long DFS(int x1, int x2, int ii, long count) { // Console.Error.WriteLine($"{x1} {x2} {ii} {count}"); // check if (x1 == N && x2 == N) { // Console.Error.WriteLine("{0}, {1}", string.Join("", X1), string.Join("", X2)); bool flg = true; for (int i = 0; i < N; i++) { if (X1[i] != X2[N - 1 - i]) { return(0); } } return(count); } int ch = CH[ii]; int ct = CT[ii]; long ret = 0; for (int k = 0; k <= ct; k++) { int skip = ct - k; long comb = COMB.Combination(ct, k); if (x1 + k > N) { continue; } if (x2 + skip > N) { continue; } bool flg = true; for (int j = 0; j < k; j++) { X1[x1 + j] = ch; int jj = x1 + j; int kk = N - 1 - jj; if (kk < x2 && X1[jj] != X2[kk]) { flg = false; } } for (int j = 0; j < skip; j++) { X2[x2 + j] = ch; int jj = x2 + j; int kk = N - 1 - jj; if (kk < (x1 + k) && X1[kk] != X2[jj]) { flg = false; } } if (!flg) { continue; } ret += DFS(x1 + k, x2 + skip, ii + 1, count * comb); } return(ret); }