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

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

๐Ÿ”ฅ Algorithm/Baekjoon

[๋ฐฑ์ค€ 1546๋ฒˆ] ํ‰๊ท  - ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ(nodejs)

Lennon 2022. 1. 17. 01:53
728x90
๋ฐ˜์‘ํ˜•

https://www.acmicpc.net/problem/1546

 

1546๋ฒˆ: ํ‰๊ท 

์ฒซ์งธ ์ค„์— ์‹œํ—˜ ๋ณธ ๊ณผ๋ชฉ์˜ ๊ฐœ์ˆ˜ N์ด ์ฃผ์–ด์ง„๋‹ค. ์ด ๊ฐ’์€ 1000๋ณด๋‹ค ์ž‘๊ฑฐ๋‚˜ ๊ฐ™๋‹ค. ๋‘˜์งธ ์ค„์— ์„ธ์ค€์ด์˜ ํ˜„์žฌ ์„ฑ์ ์ด ์ฃผ์–ด์ง„๋‹ค. ์ด ๊ฐ’์€ 100๋ณด๋‹ค ์ž‘๊ฑฐ๋‚˜ ๊ฐ™์€ ์Œ์ด ์•„๋‹Œ ์ •์ˆ˜์ด๊ณ , ์ ์–ด๋„ ํ•˜๋‚˜์˜ ๊ฐ’์€ 0๋ณด

www.acmicpc.net

 

const fs = require('fs');
let input = fs
  .readFileSync('/dev/stdin')
  .toString()
  .trim()
  .split('\n');

const count = +input[0];
let score = input[1].split(' ').map((v) => +v);

const max = Math.max(...score);

score = score.map((v) => (v / max) * 100);

console.log(score.reduce((prev, cur) => prev + cur, 0) / count);

์ธํ’‹์ด ์ด๋ ‡๊ฒŒ ๋“ค์–ด์˜ค๋ฏ€๋กœ

 

์ฒซ ๋ฒˆ์งธ ์ž…๋ ฅ => ๋งˆ์ง€๋ง‰์— ๋‚˜๋ˆŒ ์ˆ˜

๋‘ ๋ฒˆ์งธ ์ž…๋ ฅ => ์ฒ˜๋ฆฌํ•˜์—ฌ ๋‹ค ๋”ํ•  ์ˆ˜ ์ด๋ฏ€๋กœ

 

์œ„์— ์ฝ”๋“œ์™€ ๊ฐ™์ด ์ž‘์„ฑํ•˜๋ฉด ๋œ๋‹ค.

728x90
๋ฐ˜์‘ํ˜•
Comments