Party Medley

면접 대비

시간 제한1초메모리 제한2048 MB

요약
최대 평가와 최소 평가의 차이가 M 이하인 세 학생 조합의 개수를 세고, 그중 평가 합이 가장 큰 값을 구한다. N은 200 이하다.
난이도

보통10점 중 4점

유형
배열, 정렬, 완전 탐색, 투 포인터
정답자
아직 제출이 없습니다

문제

ICPC University has NN students, numbered from 11 to NN, in its Competitive Programming club. Student ii has a rating of R_iR\_i representing their estimated skill in competitive problem-solving.

Contest season is coming and Morgan, the coach of the Competitive Programming club, would like to send at most one good team to a particular contest due to their limited budget. A team consists of exactly 33 different students. Suppose that a team consists of student ii, jj, and kk. Their team rating is A_i+A_j+A_kA\_i + A\_j + A\_k, and their rating difference is max⁡(A_i,A_j,A_k)−min⁡(A_i,A_j,A_k)\max(A\_i , A\_j , A\_k) - \min(A\_i , A\_j , A\_k).

Morgan believes that a team is balanced if their rating difference is no more than a threshold of MM. Additionally, he also would like the team rating to be as large as possible while being a balanced team as well.

Morgan asks you to compute two values. The first value is the number of different balanced team configurations that can be made. The second value is the largest team rating of a balanced team that can be made.

Two team configurations are different if and only if there is at least one different student between those team configurations.

입력

Input begins with two integers NN MM (3≤N≤2003 ≤ N ≤ 200; 0≤M≤40000 ≤ M ≤ 4000) representing the number of students and the threshold for rating difference, respectively. The next line contains NN integers A_iA\_i (0≤A_i≤40000 ≤ A\_i ≤ 4000) representing the rating of student ii.

출력

If there is at least one balanced team configuration, then output two space-separated integers in a single line representing the number of different balanced team configurations and the largest team rating of any balanced team, respectively.

If there is no balanced team configuration, then output -1 in a single line.

예제4

  1. 예제 1

    입력
    5 150
    1400 1425 1250 4000 1300
    
    예상 출력
    2 4125
    
  2. 예제 2

    입력
    4 100
    2000 1900 1800 2100
    
    예상 출력
    -1
    
  3. 예제 3

    입력
    8 4000
    100 200 300 400 500 600 700 800
    
    예상 출력
    56 2100
    
  4. 예제 4

    입력
    8 0
    10 10 10 20 20 20 30 30
    
    예상 출력
    2 60