From 2ec719ec3ec6afc6739e2dfede97272994c28ef1 Mon Sep 17 00:00:00 2001 From: luckylooky2 Date: Wed, 31 Jul 2024 16:47:35 +0900 Subject: [PATCH] =?UTF-8?q?07.31:=20math(=ED=8F=89=EA=B7=A0=EC=9D=80=20?= =?UTF-8?q?=EB=84=98=EA=B2=A0=EC=A7=80)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- baekjoon/4344.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 baekjoon/4344.js diff --git a/baekjoon/4344.js b/baekjoon/4344.js new file mode 100644 index 0000000..070c7e1 --- /dev/null +++ b/baekjoon/4344.js @@ -0,0 +1,19 @@ +// 평균은 넘겠지 : 수학 +const input = require("fs") + .readFileSync("/dev/stdin") + .toString() + .trim() + .split("\n") + .map((v) => v.split(" ").map((v) => Number(v))); +const [caseNum] = input.shift(); +const testCases = input; +const answer = []; + +for (const [studentNum, ...scores] of testCases) { + const total = scores.reduce((acc, curr) => acc + curr, 0); + const avg = total / studentNum; + const overAvg = scores.filter((v) => v > avg).length; + answer.push(Math.round((overAvg / studentNum) * 100 * 1000)); +} + +console.log(answer.map((v) => `${v / 1000}%`).join("\n"));