π₯ Algorithm/Baekjoon
[λ°±μ€ 4344λ²] νκ· μ λκ² μ§ μλ°μ€ν¬λ¦½νΈ(nodejs)
Lennon
2022. 1. 17. 02:21
728x90
λ°μν
https://www.acmicpc.net/problem/4344
4344λ²: νκ· μ λκ² μ§
λνμ μλ΄κΈ°λ€μ 90%λ μμ μ΄ λ°μμ νκ· μ λλλ€κ³ μκ°νλ€. λΉμ μ κ·Έλ€μκ² μ¬ν μ§μ€μ μλ €μ€μΌ νλ€.
www.acmicpc.net
const fs = require('fs');
let input = fs.readFileSync('dev/stdin').toString().trim().split('\n');
input.shift();
input = input
.map((v) => v.split(' '))
.map((v) => v.map((v) => +v))
.filter((v) => v.shift());
input.filter((v) => {
const avg = v.reduce((prev, cur) => prev + cur) / v.length;
let count = 0;
v.filter((v1) => {
if (v1 > avg) {
count++;
}
});
console.log(((count / v.length) * 100).toFixed(3) + '%');
});
μμ λ°±μ€μ μ λ ₯κ°μ μ‘°μ νλ κ² λ νλ€λ€..
ν΄λΉ μ λ ₯κ°μ μ²λ¦¬ν κ²°κ³Ό μ½λμ΄λ€. μμ μ«μλ€μ νμμμΌλ―λ‘ λ€ shift μ²λ¦¬ ν΄μ€¬λ€.
728x90
λ°μν