Problem 2: Dog Exhibit
The dogs want to prove to the public that they are both smart and funny. In
order to do this, Bessie has organized an exhibition that will be put on by the
dogs. She has given each of the N (1 < N < 100) dogs a thorough interview and
determined two values for each dogs: the smartness Si ( -1000 < Si < 1000) of
the dog and the funniness Fi ( -1000 < Fi < 1000) of the dog.
Bessie must choose which dogs she wants to bring to her exhibition. She
believes that the total smartness ST of the group is the sum of the Si and,
likewise, the total funniness FT of the group is the sum of the Fi. Bessie wants
to maximize the sum of ST and FT , but she also wants both of these values
to be non-negative (since she must also show that the dogs are well-rounded; a
negative ST or FT would ruin this). Help Bessie maximize the sum of ST and
FT without letting either of these values become negative.
Problem name: exhibit
Input Format
* Line 1: A single integer: N.
* Line 2..1+N: Two space-separated numbers: Si and Fi
Sample Input
5
-5 7
8 -6
6 -3
2 1
-8 -5
Input Details:
You can expect input to be valid (i.e. there will be a valid solution with non-negative ST and FT).
Output Format
* Line 1: A single integer represented the maximum sum of ST and FT such
that neither is negative (ST >= 0 and FT >= 0).
Sample Output
8
Output Details
The optimal sum of smartness and funniness for the given set of dogs is 8.
Feel free to publicly post your solutions here, on your own blog, or e-mail them to [email protected]
Bruteforcing is allowed but code will be tested against a corner case (i.e. N=100) which means there are 1.2676506e30 possibilities, so good luck with that ;]