Woburn Challenge 2018-19 Round 3 - Junior Division
Problem 2: Net Weight
Oh boy, is it ever Team Rocket's lucky day: They've stumbled upon a gathering of N (1 ≤ N ≤ 100) wild, defenseless Pikachus! This is their chance to snatch up as many of these priceless Pokémon as they can!
Jessie and James each have a net, which can allow them to catch at most one Pikachu each. There's just one possible caveat: Each net can only hold a Pikachu which weighs at most 100 pounds. The i-th of the N Pikachus has a weight of Wi (1 ≤ Wi ≤ 200) pounds.
Heavier Pikachus are sure to be more valuable, so Team Rocket would like to catch the heaviest ones they can. Given that Jessie and James each choose at most one Pikachu to catch (and don't both catch the same Pikachu), such that each of their chosen Pikachus weighs at most 100 pounds, what's the maximum possible sum of Pikachu weights which they can get their hands on?
Input Format
The first line of input consists of a single integer, N.
N lines follow, the i-th of which consists of a single integer, Wi, for i = 1..N.
Output Format
Output a single integer, the maximum combined weight of Pikachus which Team Rocket can catch (in pounds).
Sample Input 1
5 43 100 31 104 62
Sample Output 1
162
Sample Input 2
3 101 1 200
Sample Output 2
1
Sample Explanation
In the first case, Jessie can catch the 2nd Pikachu while James catches the 5th Pikachu, for a combined weight of 100 + 62 = 162 pounds.
In the second case, Jessie can catch the 2nd Pikachu while James catches none.
All Submissions
Best Solutions
Point Value: 5 (partial)
Time Limit: 2.00s
Memory Limit: 16M
Added: Feb 01, 2019
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...