DMPG '15 B4 - Maximum Product

View as PDF

Submit solution

Points: 7
Time limit: 1.0s
Memory limit: 64M

Problem type

Bob is playing a card game with his friends, where each card has a number on it. The goal of the game is to make the largest number possible with the cards in his hand. In order to create this number, Bob must pick a subset of at least one card from all of the cards he has in his hand and multiply them. To add to the difficulty of the game, there are cards with negative numbers. Can you help Bob create the largest possible number with his hand?

Input Specification

The first line will contain an integer N (1\le N \le 30), which will represent the number of cards in Bob's hand.

For the next N lines, line i will contain a single integer c (-5 \le c \le 5), representing the value of the i^{th} card in Bob's hand.

Output Specification

A single integer, the maximum product Bob can make with his cards.

Sample Input 1

5
0
1
2
3
4

Sample Output 1

24

Sample Input 2

5
-2
-3
-4
3
1

Sample Output 2

36

Comments

There are no comments at the moment.