Notice
Recent Posts
Recent Comments
Link
ยซ   2025/01   ยป
์ผ ์›” ํ™” ์ˆ˜ ๋ชฉ ๊ธˆ ํ† 
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
Archives
Today
Total
๊ด€๋ฆฌ ๋ฉ”๋‰ด

Lennon FE

[๋ฐฑ์ค€ 3009๋ฒˆ] ๋„ค ๋ฒˆ์งธ ์  - ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ(nodejs) ๋ณธ๋ฌธ

๐Ÿ”ฅ Algorithm/Baekjoon

[๋ฐฑ์ค€ 3009๋ฒˆ] ๋„ค ๋ฒˆ์งธ ์  - ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ(nodejs)

Lennon 2022. 1. 25. 22:54
728x90
๋ฐ˜์‘ํ˜•

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

 

3009๋ฒˆ: ๋„ค ๋ฒˆ์งธ ์ 

์„ธ ์ ์ด ์ฃผ์–ด์กŒ์„ ๋•Œ, ์ถ•์— ํ‰ํ–‰ํ•œ ์ง์‚ฌ๊ฐํ˜•์„ ๋งŒ๋“ค๊ธฐ ์œ„ํ•ด์„œ ํ•„์š”ํ•œ ๋„ค ๋ฒˆ์งธ ์ ์„ ์ฐพ๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค.

www.acmicpc.net

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

let x = input.map((v) => v[0]).sort((a, b) => a - b);
let y = input.map((v) => v[1]).sort((a, b) => a - b);

x = x[0] === x[1] ? x[2] : x[0];
y = y[0] === y[1] ? y[2] : y[0];

console.log(x, y);

๊ฐ ์ขŒํ‘œ๋ฅผ ์ •๋ ฌํ•œ ํ›„

๊ฐ ์ขŒํ‘œ์˜ ์ฒซ ๋ฒˆ์งธ์™€ ๋‘ ๋ฒˆ์งธ๊ฐ€ ๊ฐ™์œผ๋ฉด ์„ธ ๋ฒˆ์งธ๋กœ ์ •ํ•ด์ค€๋‹ค.

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