Solve Me And Get Chocolates
Practice
4.7 (3 votes)
Problem
78% Success 441 Attempts 20 Points 2s Time Limit 256MB Memory 1024 KB Max Code

"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  s 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 s of the ith chocolate. 

 

OUTPUT :

The sum of the sweetness of the K chocolates you received. 

 

CONSTRAINTS : 

25 Marks :   N < 103   &   K < 10 & 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

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
15 votes
Tags:
Ad-HocBasic ProgrammingOpenApprovedEasyMathamatics
Points:20
11 votes
Tags:
MathematicsOpenApprovedEasyMathamatics
Points:20
1 votes