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# (Mono 4.6.2.0) (judge verdict: Accepted)

using Yorukatsu029.Questions;
using Yorukatsu029.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Yorukatsu029.Questions
{
    public class QuestionF : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var nab = inputStream.ReadIntArray();
            var n = nab[0];
            var a = nab[1];
            var b = nab[2];
            var values = inputStream.ReadLongArray();

            var totalValues = new ValueAndCount[n + 1, b + 1];
            totalValues[0, 0] = new ValueAndCount(0, 1);

            for (int candidate = 1; candidate <= n; candidate++)
            {
                for (int selected = 0; selected <= b; selected++)
                {
                    // 選ばない
                    totalValues[candidate, selected] = totalValues[candidate - 1, selected];

                    if (selected > 0)
                    {
                        // 選ぶ
                        var previous = totalValues[candidate - 1, selected - 1];
                        var current = new ValueAndCount(previous.Value + values[candidate - 1], previous.Count);
                        var compare = current.CompareTo(totalValues[candidate, selected]);

                        if (compare > 0)
                        {
                            totalValues[candidate, selected] = new ValueAndCount(current.Value, previous.Count);
                        }
                        else if (compare == 0)
                        {
                            totalValues[candidate, selected] = new ValueAndCount(current.Value, totalValues[candidate, selected].Count + previous.Count);
                        }
                    }
                }
            }

            decimal maxAverage = decimal.MinValue;
            long count = 0;

            for (int selected = a; selected <= b; selected++)
            {
                var current = totalValues[n, selected];
                var average = (decimal)current.Value / selected;
                if (average.CompareTo(maxAverage) > 0)
                {
                    maxAverage = average;
                    count = current.Count;
                }
                else if (average.CompareTo(maxAverage) == 0)
                {
                    count += current.Count;
                }
            }

            yield return maxAverage;
            yield return count;
        }

        struct ValueAndCount : IComparable<ValueAndCount>
        {
            public long Value { get; }
            public long Count { get; }

            public ValueAndCount(long value, long count)
            {
                Value = value;
                Count = count;
            }

            public int CompareTo(ValueAndCount other) => Value.CompareTo(other.Value);

            public override string ToString() => $"Value:{Value}, Count:{Count}";
        }
    }
}


namespace Yorukatsu029
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionF();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace Yorukatsu029.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace Yorukatsu029.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion