Algorithm
- ํ๊ท ์ ๋๊ฒ ์ง -
๋ฌธ์
๋ํ์ ์๋ด๊ธฐ๋ค์ 90%๋ ์์ ์ด ๋ฐ์์ ํ๊ท ์ ๋๋๋ค๊ณ ์๊ฐํ๋ค.
๋น์ ์ ๊ทธ๋ค์๊ฒ ์ฌํ ์ง์ค์ ์๋ ค์ค์ผ ํ๋ค.
์ ์ถ๋ ฅ ์์
๋ฌธ์ ํ๊ธฐ
let fs = require("fs");
let input = fs.readFileSync("/dev/stdin")
.toString()
.trim()
.split("\n")
.map((el) => el.split(" ").map((el) => Number(el)));
input.shift();
let percent = [];
for (let i = 0; i < input.length; i++) {
let grade = input[i].slice(1, input[i].length);
let avg = grade.reduce((past, curr) => past + curr, 0) / grade.length;
let pass = grade.filter((el) => el > avg).length;
let onePercent = ((pass / grade.length) * 100).toFixed(3);
percent.push(onePercent);
}
console.log(percent.join("%\n") + "%");
๋ฐ์ํ
'๊ฐ์ธ๊ณต๋ถ > Algorithm' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[๋ฐฑ์ค][Node.js] 4504๋ฒ : ๋ฐฐ์ ์ฐพ๊ธฐ (0) | 2021.10.26 |
---|---|
[๋ฐฑ์ค][Node.js] 4458๋ฒ : ์ฒซ ๊ธ์๋ฅผ ๋๋ฌธ์๋ก (0) | 2021.10.25 |
[๋ฐฑ์ค][Node.js] 4153๋ฒ : ์ง๊ฐ์ผ๊ฐํ (0) | 2021.10.21 |
[๋ฐฑ์ค][Node.js] 3052๋ฒ : ๋๋จธ์ง (0) | 2021.10.20 |
[๋ฐฑ์ค][Node.js] 3046๋ฒ : R2 (0) | 2021.10.19 |
๋๊ธ