Midnight Snack
Output: Standard Output (stdout)
Memory limit: 64 megabytes
Time limit: 0.5 seconds
Andrew has unfortunately stayed up way too late and is now hungry for a midnight snack. Andrew has N cookies (1 \le N \le 10,000), the i-th of which has a tastiness t_i (1 \le t_i \le 100).
Andrew will only eat a cookie if it has a tastiness of at least K (1 \le K \le 100) where K is some fixed integer. Andrew has asked for your help to write a program to find the total sum of the tastiness of the cookies that he can eat.
Input
The first line contains N - the number of cookies.
The second line contains K - the minimum tastiness a cookie must have for Andrew to eat it.
The next N lines each contain the tastiness of each cookie, t_1, t_2, \dots, t_N, each on their own line.
Output
Output a single integer, the maximum sum of the tastiness of the cookies Andrew could eat.
Subtasks
- Subtask 1 (40%): K = 1
- Subtask 2 (60%): No further constraints.
Sample Explanations
Sample 1
In the first sample, Andrew has 5 cookies, and will only eat a cookie if it has tastiness at least 1. All the cookies have a tastiness of at least 1 so he can eat all of them, which gives a total tastiness of 1+2+3+4+5=15.
Sample 2
In the second sample, Andrew has 6 cookies, and will only eat a cookie if it has tastiness at least 7. So, the only cookies he can eat is the one with tastiness 7 and the one with tastiness 12. This gives a total tastiness of 7+12=19.
-
Sample Input 1
5 1 1 2 3 4 5
Sample Output 1
15
-
Sample Input 2
6 7 1 7 3 12 4 6
Sample Output 2
19