题解 | #记负均正II#
记负均正II
https://www.nowcoder.com/practice/64f6f222499c4c94b338e588592b6a62
const rl = require("readline").createInterface({ input: process.stdin });
var iter = rl[Symbol.asyncIterator]();
const readline = async () => (await iter.next()).value;
void async function () {
// Write your code here
const arr = [];
const brr = []; // 非负数
const crr = []; // 负数
let res = 0;
while(line = await readline()){
arr.push(line);
}
arr.forEach((val) => {
if (parseInt(val) > 0) {
brr.push(val);
} else {
crr.push(val);
}
});
if (brr.length > 0) {
for (let i = 0; i < brr.length; i++) {
res += parseInt(brr[i]);
}
}
console.log(crr.length);
console.log((res/brr.length).toFixed(1));
}()