Woburn Challenge 2015-16 Round 2 - Junior Division
Problem V: The Empire Strikes Back
“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 ≤ N ≤ 100) rocks on the ground, with the i-th rock having a mass of Wi (1 ≤ Wi ≤ 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 ≤ M ≤ 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 Format
The first line of input consists of two space-separated integers N and M.
The next N lines each consist of a single integer Wi, for i = 1..N.
Output Format
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.
All Submissions
Best Solutions
Point Value: 5
Time Limit: 2.00s
Memory Limit: 16M
Added: Dec 12, 2015
Author: SourSpinach
Languages Allowed:
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3
Comments (Search)
It's quiet in here...