Submit solution

Points:
7 (partial)

Time limit:
0.6s

Memory limit:
64M

Author:

Problem type

Allowed languages

Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, ~~CommonLisp~~, D, Dart, F#, Forth, Fortran, Go, ~~Groovy~~, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, ~~Nim~~, ~~ObjC~~, OCaml, ~~Octave~~, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

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 , 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.

#### 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

Any thoughts on why I'm getting 1 for cases 5 and 10?

Does your code overlook a scenario with only 0s? What about 0s and 1 negative number? Or what if there is only 1 number, and that is a negative?

Don't overlook any possible situations, unless specified in the problem statement.

Occasionally, I get 5625 for test case #4. I assume this has to do with the selection of the judge, but I can't find anything non-standard with my code.

You are sorting

`short`

but you are casting them to`int*`

in the comparator.Ahh... Thanks