"Teddy Daniels Is In Control, And Is Still Delusional" .
The problem setter loves movies and you love chocolates. Each chocolate has some sweetness si associated with it , where sweetness of a chocolate is always positive. The problem setter has infinite chocolates , one of each possible sweetness. Now , you are already an avid chocolate fan , so you have N chocolates with you. But you want K more chocolates.
You tell the problem setter the sweetness si of all the N chocolates that are with you and ask him to give you K chocolates whose sweetness is not already present with you.
But at the same time , you are also conscious about your health and do not want to consume too much sweet. Hence , you ask the setter to give you K chocolates , whose sweetness is not already present with you and their sweetness is as less as possible.
What is the sum of the sweetness of all the K chocolates you will get from the setter. Answer this correctly and the chocolates are yours.
INPUT :
The first line has 2 integers N and K , denoting the number of chocolates with you and the number of more chocolates you want.
The next line contains N integers , where ith integer is the sweetness si of the ith chocolate.
OUTPUT :
The sum of the sweetness of the K chocolates you received.
CONSTRAINTS :
25 Marks : N < 103 & K < 103 & si < 107
25 Marks : N < 103 & K < 105 & si < 107
25 Marks : N < 105 & K < 105 & si < 107
25 Marks : N < 105 & K < 108 & si < 109
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Login to unlock the editorial