본문 바로가기

코딩테스트 연습25

[백준] 1654번 랜선 자르기(JavaScript) https://www.acmicpc.net/problem/1654let input = require('fs') .readFileSync(process.platform === 'linux' ? '/dev/stdin' : './input.txt') .toString() .trim() .split('\n'); let [K, N] = input.shift().split(' ').map(Number); input = input.map(Number).sort((a, b) => a - b); let start = 0; let end = input[K - 1]; let answer = Number.MIN_SAFE_INTEGER; while(start acc + Math.floor(cur / m.. 2024. 5. 7.
[백준] 10816번 숫자 카드2(JavaScript) https://www.acmicpc.net/problem/108161. 객체 방법let input = require('fs') .readFileSync(process.platform === 'linux' ? '/dev/stdin' : './input.txt') .toString() .trim() .split('\n') .map((el) => el.split(' ').map(Number));let N = input.shift()[0];let first = input.shift().sort((a, b) => a - b);let M = input.shift()[0];let second = input.shift();let classFirst = first.reduce((acc, cur) => { ac.. 2024. 5. 6.
[백준] 10815번 숫자 카드(JavaScript) https://www.acmicpc.net/problem/10815let input = require('fs') .readFileSync(process.platform === 'linux' ? '/dev/stdin' : './input.txt') .toString() .trim() .split('\n') .map((el) => el.split(' ').map(Number));let N = input.shift()[0];let first = input.shift().sort((a, b) => a - b);let M = input.shift()[0];let second = input.shift();let answer = [];second.forEach((el) => { let start = 0; .. 2024. 5. 4.
[백준] 1764번 듣보잡(JavaScript) https://www.acmicpc.net/problem/1764const input = require('fs') .readFileSync(process.platform === 'linux' ? '/dev/stdin' : './input.txt') .toString() .trim() .split('\n');// .map((el) => el.split(' ').map(Number));// .map(Number);const [N, M] = input.shift().split(' ').map(Number);let x = new Set(input.slice(0, N));let y = new Set(input.slice(N));let answer = [];x.forEach((el) => { if (y.h.. 2024. 5. 3.