๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

ํ”„์—” ๊ณต๋ถ€/๐Ÿซง ์•Œ๊ณ ๋ฆฌ์ฆ˜ ๊ณต๋ถ€

[๋ฐฑ์ค€/Node.js] 1546๋ฒˆ ํ‰๊ท  || ํ’€์ด JavaScript

728x90
let input = require('fs').readFileSync('/dev/stdin').toString().trim().split("\n").map(i => i.split(" "));

const n = input[0];
const subs = input[1];

const m = Math.max(...subs);

const raiseScore = (subs, maxSub) => {
    let newScores = subs.map(v => v / maxSub * 100);
    return newScores.reduce((sum, v) => sum + v) / n;
}

console.log(raiseScore(subs, m));

๋ฌธ์ œ ํ’€์ด๋ฅผ ํ•  ๋•Œ ๋จผ์ € ์ฝ”๋“œ๋ฅผ ์“ฐ์ง€ ๋ง๊ณ , 

์–ด๋–ค ์ ˆ์ฐจ๋กœ ๊ฐ’์„ ๊ตฌํ• ์ง€ ๋จผ์ € ์“ฐ๋Š” ์—ฐ์Šต์„ ์‹œ์ž‘ํ–ˆ๋‹ค. 

 

๋…ธํŠธ์— ๋จผ์ € ์ •๋ฆฌ ํ›„ ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ–ˆ๋Š”๋ฐ, 

ํ™•์‹คํžˆ ๋ฉ~ ํ•˜๋‹ˆ ์ฝ”๋“œ๋ฅผ ๋ณด๊ณ  ์žˆ๋Š” ์‹œ๊ฐ„์ด ์ค„์—ˆ๊ณ , 

์ค‘๊ฐ„์ค‘๊ฐ„ ๋‚ด๊ฐ€ ์ฝ”๋“œ๋ฅผ ์งœ๋‹ค๊ฐ€ ํ—ท๊ฐˆ๋ฆฌ๋Š” ๋ถ€๋ถ„์ด ์ค„์—ˆ๋‹ค.

 

<์ •๋ฆฌ ๋‚ด์šฉ>

1. ์ตœ๋Œ€๊ฐ’ ๋จผ์ € ๊ตฌํ•˜๊ธฐ

2. ๊ฐ’๋“ค์„ ๊ณต์‹์— ๋„ฃ๊ธฐ

3. ์ƒˆ๋กœ์šด ํ‰๊ท  ๊ตฌํ•˜๊ธฐ

 

 

 

๊ทธ๋ฆฌ๊ณ 

1์ฐจ์› ๋ฐฐ์—ด ๋‹จ๊ณ„ ๋~

728x90
๋ฐ˜์‘ํ˜•