#600
Bronze II
Cow College
시간 제한
2s
메모리 제한
1024MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

Farmer John is planning to open a new university for cows!

There are NN (1N1051 \le N \le 10^5) cows who could potentially attend this university. Each cow is willing to pay a maximum tuition of cic_i (1ci1061 \le c_i \le 10^6). Farmer John can set the tuition that all cows must pay to enroll. If this tuition is greater than the maximum a cow is willing to pay, then the cow will not attend the university. Farmer John wants to make the most possible money so he can pay his instructors a fair wage. Please determine how much money he can make, and how much tuition he should charge.

입력

The first line contains NN. The second line contains NN integers c1,c2,,cNc_1, c_2, \dots, c_N, where cic_i is the maximum tuition cow ii is willing to pay.

출력

Please output the maximum amount of money Farmer John can make and the optimal tuition he should charge. If there are multiple solutions, output the solution with the smallest optimal tuition.

Note that the large size of integers involved in this problem may require the use of 64-bit integer data types (e.g., a "long" in Java, a "long long" in C/C++).

예제 입력 1

4
1 6 4 6

예제 출력 1

12 4

점수

Test cases 2 through 4 have ci1,000c_i \le 1{,}000. Test cases 5 through 8 have N5,000N \le 5{,}000. Test cases 9 through 12 have no additional constraints.

코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Bronze II1명 투표· 약 1개월 전
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.