184. Close Product

Codeforces
IDCF10269184
Time1000ms
Memory256MB
Difficulty
English · Original
Formal · Original
You have $n$ positive integers, and you want to find their product. However, you have to omit exactly one of the integers from the list before calculating the product. You want to find the maximum product of the list, after omitting exactly one integer from the list. For example, given the numbers $2$, $4$, and $5$, the maximum product is $5$ * $4$ = $20$. $2$ * $4$ * $5$ is not valid, because none of the numbers were omitted. The first line of input contains a single positive integer $n$: the number of integers in the list. The next $n$ lines each contain a single positive integer: each element of the list. Output a single positive integer $p$: the maximum possible product of all integers in the list, if you omit exactly one. The answer is guaranteed to fit inside of a 32-bit integer type. ## Input The first line of input contains a single positive integer $n$: the number of integers in the list.The next $n$ lines each contain a single positive integer: each element of the list. ## Output Output a single positive integer $p$: the maximum possible product of all integers in the list, if you omit exactly one. The answer is guaranteed to fit inside of a 32-bit integer type. [samples]
**Definitions** Let $ n \in \mathbb{Z}^+ $ be the number of integers. Let $ A = (a_1, a_2, \dots, a_n) $ be a sequence of positive integers. **Constraints** $ n \geq 2 $, and $ a_i \in \mathbb{Z}^+ $ for all $ i \in \{1, \dots, n\} $. The result fits in a 32-bit integer. **Objective** Compute: $$ \max_{j \in \{1, \dots, n\}} \left( \prod_{\substack{i=1 \\ i \neq j}}^{n} a_i \right) $$
API Response (JSON)
{
  "problem": {
    "name": "184. Close Product",
    "description": {
      "content": "You have $n$ positive integers, and you want to find their product. However, you have to omit exactly one of the integers from the list before calculating the product. You want to find the maximum pro",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10269184"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You have $n$ positive integers, and you want to find their product. However, you have to omit exactly one of the integers from the list before calculating the product. You want to find the maximum pro...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ n \\in \\mathbb{Z}^+ $ be the number of integers.  \nLet $ A = (a_1, a_2, \\dots, a_n) $ be a sequence of positive integers.\n\n**Constraints**  \n$ n \\geq 2 $, and $ a_i \\in \\mathbb{...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments