Skip to content

Commit

Permalink
07.31: math(평균은 넘겠지)
Browse files Browse the repository at this point in the history
  • Loading branch information
luckylooky2 committed Jul 31, 2024
1 parent ed1996b commit 2ec719e
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions baekjoon/4344.js
Original file line number Diff line number Diff line change
@@ -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"));

0 comments on commit 2ec719e

Please sign in to comment.