Jerry and Adding Numbers

0

0 votes
Problem

Jerry likes to play games, and this time he has invited you to play with him a new game of adding number 1. The game is as follows: Jerry gives you an array of n integers, a number K and defines a operation that can be performed on elements of this given array at most K times. The operation is very simple, that is you can choose any element of the array and increase it by 1.

By giving all this information, Jerry asks you to find the element in the array with the maximum frequency( which is repeated maximum number of times) after performing at most K operations.

Input:

The first line contains an integer t, denoting t test cases. 2*t lines follow.

The first line of each test case has 2 numbers N and K, the size of the array and the maximum number of operations allowed.

The next line contains N space separated integers denoting the array of size N.

Output:

For each test case, print two numbers, the maximum frequency of some number in the array after at most K operations are performed and the number itself whose frequency is maximum.

If there are multiple numbers whose frequency reaches the maximum, then output the smallest of them. Separate the 2 numbers by a whitespace.

Constraints:

    1 <= t <= 10
    1 <= N <= 10^5
    0 <= K <= 10^9
    |a[i]| <= 10^9
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

In the sample test case, you can increase the first and the second element by 1, so that the array becomes 2 2 2 2 3, where frequency of number 2 is 4.

Editor Image

?