WC '18 Contest 3 J2 - Net Weight

View as PDF

Submit solution

Points: 5 (partial)
Time limit: 1.0s
Memory limit: 16M

Problem type
Woburn Challenge 2018-19 Round 3 - Junior Division

Oh boy, is it ever Team Rocket's lucky day: They've stumbled upon a gathering of N (1 \le N \le 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 W_i (1 \le W_i \le 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 Specification

The first line of input consists of a single integer, N.
N lines follow, the i-th of which consists of a single integer, W_i, for i = 1 \dots N.

Output Specification

Output a single integer, the maximum combined weight of Pikachus which Team Rocket can catch (in pounds).

Sample Input 1


Sample Output 1


Sample Input 2


Sample Output 2


Sample Explanation

In the first case, Jessie can catch the 2-nd Pikachu while James catches the 5-th Pikachu, for a combined weight of 100 + 62 = 162 pounds.

In the second case, Jessie can catch the 2-nd Pikachu while James catches none.


There are no comments at the moment.