Notice
Recent Posts
Recent Comments
Link
ยซ   2024/11   ยป
์ผ ์›” ํ™” ์ˆ˜ ๋ชฉ ๊ธˆ ํ† 
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
Archives
Today
Total
๊ด€๋ฆฌ ๋ฉ”๋‰ด

Lennon FE

[๋ฐฑ์ค€ 4344๋ฒˆ] ํ‰๊ท ์€ ๋„˜๊ฒ ์ง€ ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ(nodejs) ๋ณธ๋ฌธ

๐Ÿ”ฅ 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
๋ฐ˜์‘ํ˜•
Comments