在纪中的第四天,2017-7-10 总结:

时间:2021-04-11 09:49:25
  1. 【2016.11.12PJ模拟】最大值
    (File IO): input:max.in output:max.out
    时间限制: 1000 ms 空间限制: 262144 KB 具体限制
    Goto ProblemSe

题目描述

给定n个数,{x1,x2,…,xn}要求从中选出至少一个数,至多n个数,使得乘积之和最大。

输入

第一行整数n,表示有多少个数
接下来n行,每行一个整数xi,-10 ≤xi≤ 10

输出

输出一行,表示最大乘积

样例输入

Sample Input1:
3
-1
2
-4

Sample Input2:
3
3
2
-4

样例输出

Sample Output1:
8

Sample Output2:
6

解:
这一题呢,我(ke)不(neng)会(ma).
就是让负数成对,正数直接乘.
最小的负数不能成对就不乘。
啦啦。

var
max,n,i,x,w,k,aj:longint;
ans:int64;

procedure aa;
begin
ans:=1;
max:=-10;
for i:=1 to n do
begin
readln(x);
if x<>0 then ans:=ans*x
else inc(w);
if x<0 then
begin
if max