DMPG '15 B4 - Maximum ProductView as PDF
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?
The first line will contain an integer , which will represent the number of cards in Bob's hand.
For the next lines, line will contain a single integer , representing the value of the card in Bob's hand.
A single integer, the maximum product Bob can make with his cards.
Sample Input 1
5 0 1 2 3 4
Sample Output 1
Sample Input 2
5 -2 -3 -4 3 1
Sample Output 2