๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๊ฐœ์ธ๊ณต๋ถ€/Algorithm

[๋ฐฑ์ค€][Node.js] 4344๋ฒˆ : ํ‰๊ท ์€ ๋„˜๊ฒ ์ง€

by ๐Ÿ‡๋ฐ•๋ด‰๋ด‰๐Ÿ‡ 2021. 10. 23.

 

 

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") + "%");

 

 

 

๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€