WC '15 Contest 2 J2 - The Empire Strikes Back

View as PDF

Submit solution


Points: 3
Time limit: 1.0s
Memory limit: 16M

Author:
Problem type
Woburn Challenge 2015-16 Round 2 - Junior Division
"Do. Or do not. There is no try/catch."

As part of his intensive Jedi training at the hands of Master Yoda in the Dagobah system, Luke has been given the task of moving some rocks. That may sound simple, but he'll have to move them with his mind, using the power of the Force! Also, some of the rocks are rather heavy.

Yoda has laid out N (1 \le N \le 100) rocks on the ground, with the i-th rock having a mass of W_i (1 \le W_i \le 100) pounds. He's instructed Luke to move all of them to another location, one at a time. Unfortunately, Luke's control of the Force is only strong enough to allow him to lift a rock if its mass is no larger than M (1 \le M \le 100) pounds.

Assuming that Luke tries his best and moves as many of the rocks as he can, what's the total mass of the rocks that he'll lift?

Input Specification

The first line of input consists of two space-separated integers N and M.
The next N lines each consist of a single integer W_i, for i = 1 \dots N.

Output Specification

Output a single integer – the total mass of rocks that Luke can lift with the force.

Sample Input

6 8
4
9
8
12
7
1

Sample Output

20

Sample Explanation

The 2nd and 4th rocks are too heavy for Luke, but he can lift the remaining 4 rocks, which have a total mass of 4 + 8 + 7 + 1 = 20 pounds.


Comments

There are no comments at the moment.