题解 | #记负均正#
记负均正
http://www.nowcoder.com/practice/6abde6ffcc354ea1a8333836bd6876b8
let arr = []
while(line = readline()) {
arr.push(line);
}
let newArr = [];
newArr.push(arr.slice(0, 2));
newArr.push(arr.slice(2));
for (let item of newArr) {
const n = parseInt(item[0]);
const listArr = item[1].split(' ').map((num) => parseInt(num));
// 负数个数
let total = listArr.filter((num) => num < 0).length;
let count = 0;
//正数数组
let zhengshu = listArr.filter((num) => num > 0);
for (let i of zhengshu) {
count += i;
}
let result = [total, (count/zhengshu.length).toFixed(1)];
print(result.join(' '));
}