SCC25 Contest 1 P1 - Candy Capacity


Submit solution


Points: 5 (partial)
Time limit: 1.0s
Memory limit: 256M

Author:
Problem type

In the strange land of AYJistan, its citizens partake in a strange custom called HAYJlloween, where people go around to different houses to collect candy. Jimmy and his gang of \(K\) lowerclassmen wish to partake, however Jimmy's parents want to know certain things about HAYJlloween before letting Jimmy and his gang partake.

Jimmy has \(N\) bags he could give out to his gang, with the \(i\)th bag able to hold \(c_{i}\) candies. Each lowerclassmen can only hold one bag. Assuming that everyone's bags will be full of candy by the end of HAYJlloween, Jimmy's parents want to know the minimum and maximum number of candies his gang could collect.

Note: Jimmy is lazy, so he will not be partaking in HAYJlloween himself.

Constraints

\(1 \leq N \leq 10^{5}\)

\(1 \leq c_{i} \leq 10^{9}\)

Subtask 1 [30%]

\(K = 1\)

Subtask 2 [70%]

\(1 \leq K \leq N \leq 10^{5}\)

Input Specification

The first line contains two integers, \(N\) and \(K\).

The second line contains \(N\) integers, \(c_{i}\).

Output Specification

Output two integers, the minimum and maximum number of candies Jimmy's gang could collect.

Sample Input

5 3
1 4 3 3 2

Sample Output

6 10

Comments

There are no comments at the moment.