Notice
Recent Posts
Recent Comments
Link
์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
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 | 31 |
Tags
- ๊ตฌ๋ฆํค ์ฑ๋ฆฐ์ง
- TypeError: createContext only works in Client Components. Add the "use client" directive at the top of the file to use it. Read more:
- js ๊ฑฐ๋ฆฌ๋๊ธฐ ํ์ธํ๊ธฐ
- js
- ๋ฐฑ์ค 1339๋ฒ nodejs
- ์๋ฐ์คํฌ๋ฆฝํธ ๋ฌธ์์ด ์์ถ
- ๋ฐฑ์ค 2108 nodejs
- next13 emotion
- ํ๋ก๊ทธ๋๋จธ์ค ๋ฌธ์์ด ์์ถ
- ์นด์นด์ค ์ฝํ
- ํ๋ก๊ทธ๋๋จธ์ค ๊ฑฐ๋ฆฌ๋๊ธฐ ํ์ธํ๊ธฐ
- emtion app router
- js ๋ฌธ์์ด ์์ถ
- ๋ฆฌ์กํธ์ฟผ๋ฆฌ suspense
- suspense ๋น๋๊ธฐ
- ๋ฐฑ์ค 1339๋ฒ js
- suspense react-query
- app router emotion
- js ์ค์ฝํ
- ๊ตฌ๋ฆํค ์ฑ๋ฆฐ์ง ํ๊ณ
- ์ค์ฝํ
- ๊ตฌ๋ฆํค
- ๋ฐฑ์ค 2108 ์๋ฐ์คํฌ๋ฆฝํธ
- ์ต์ ๋์ฒด์ด๋
- suspense ๋์์๋ฆฌ
- suspense ๋ณ๋ชฉํ์
- ๋ฐฑ์ค 1339๋ฒ ์๋ฐ์คํฌ๋ฆฝํธ
- emotion RSC
- ์ฌ์ฉ์ฑ ๊ฐ์
- ์๋ฐ์คํฌ๋ฆฝํธ ์ค์ฝํ
Archives
- Today
- Total
Lennon FE
[๋ฐฑ์ค 2108๋ฒ] ํต๊ณํ - ์๋ฐ์คํฌ๋ฆฝํธ(nodejs) ๋ณธ๋ฌธ
๐ฅ Algorithm/Baekjoon
[๋ฐฑ์ค 2108๋ฒ] ํต๊ณํ - ์๋ฐ์คํฌ๋ฆฝํธ(nodejs)
Lennon 2022. 5. 3. 18:52728x90
๋ฐ์ํ
https://www.acmicpc.net/problem/2108
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
let input = [];
rl.on('line', function (line) {
input.push(line);
if (input.length === +input[0] + 1) {
rl.close();
}
}).on('close', function () {
const [N, ...nums] = input.map(Number);
nums.sort((a, b) => a - b);
const avg = Math.round(nums.reduce((acc, cur) => acc + cur, 0) / nums.length);
const median = nums[Math.floor(nums.length / 2)];
const obj = {};
for (let i = 0; i < N; i++) {
if (!obj[nums[i]]) {
obj[nums[i]] = 1;
} else {
obj[nums[i]] += 1;
}
}
const modeArr = Object.entries(obj).sort((a, b) => b[1] - a[1]);
const value = modeArr[0][1];
console.log(avg === 0 ? +0 : avg);
console.log(median);
if (nums.length > 1 && modeArr[1][1] === value) {
const maxModeArr = modeArr.filter((v) => v[1] === value);
maxModeArr.sort((a, b) => +a[0] - +b[0]);
console.log(+maxModeArr[1][0]);
} else {
console.log(+modeArr[0][0]);
}
if (nums.length > 1) {
console.log(Math.abs(nums[nums.length - 1] - nums[0]));
} else {
console.log(0);
}
});
์ต๋น๊ฐ์์ ์ ๋ ฌ์ ์ ํ๋ ๊ฒ์ ์ฐพ๋๊ฒ ์ค์ ์ด๋ค! - ๋ณธ์ธ์ ์ ๋ ฌ์ ์ ํ ์ํ์ธ์ง ๋ชจ๋ฅด๊ณ ์ด๋๊ฐ ํ๋ฆฐ์ง ์ฐพ๋๋ผ ๊ณ ์ํ๋ค
728x90
๋ฐ์ํ
'๐ฅ Algorithm > Baekjoon' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[๋ฐฑ์ค 2607๋ฒ] ๋น์ทํ ๋จ์ด - ์๋ฐ์คํฌ๋ฆฝํธ(nodejs) (0) | 2022.05.07 |
---|---|
[๋ฐฑ์ค 14612๋ฒ] ๊น์๋น - ์๋ฐ์คํฌ๋ฆฝํธ(nodejs) (0) | 2022.05.05 |
[๋ฐฑ์ค 1759๋ฒ] ์ํธ ๋ง๋ค๊ธฐ - ์๋ฐ์คํฌ๋ฆฝํธ(nodejs) (0) | 2022.05.02 |
[๋ฐฑ์ค 14503๋ฒ] ๋ก๋ด์ฒญ์๊ธฐ - ์๋ฐ์คํฌ๋ฆฝํธ(nodejs) (0) | 2022.04.30 |
[๋ฐฑ์ค 9935๋ฒ] ๋ฌธ์์ด ํญ๋ฐ - ์๋ฐ์คํฌ๋ฆฝํธ(nodejs) (0) | 2022.04.06 |
Comments