传统题 1000ms 256MiB

A-1 Maximum Product

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

Given nn integers a1,a2,,ana_1, a_2, \cdots , a_n . For each 1in1\le i\le n ,the maximum product for aia_i is defined to be pi=maxijnaiajp_i = \max _{i\le j\le n} a_i a_j . Your job is to calculate the maximum products for all the nn integers.

输入格式

Each input file contains one test case. The first line gives a positive integer nn ( 105\le 10^5 ). Then nn integers follow in the next line, each in the interval [104,104][-10^4, 10^4] .

All the numbers in a line are separated by a space.

输出格式

For each test case, print in a line the maximum products of all the given nn integers. All the numbers in a line must be separated by 1 space, and there must be no extra space at the beginning or the end of the line.

题目示例数据

4
1 4 -9 6
6 24 81 36

PAT2025春季重现赛

未参加
状态
已结束
规则
IOI
题目
11
开始于
2025-7-20 14:00
结束于
2025-7-20 17:30
持续时间
3.5 小时
主持人
参赛人数
46