From e6460c7fb28778f7cc7869ecec20f50056c3fcd2 Mon Sep 17 00:00:00 2001 From: Janghyeon Hwang <104212460+eric-hjh@users.noreply.github.com> Date: Mon, 24 Feb 2025 23:11:00 +0900 Subject: [PATCH 1/4] =?UTF-8?q?84=EC=B0=A8=201=EB=B2=88=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=ED=92=80=EC=9D=B4=EC=9D=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../\355\231\251\354\236\245\355\230\204.js" | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 "live8/test84/\353\254\270\354\240\2341/\355\231\251\354\236\245\355\230\204.js" diff --git "a/live8/test84/\353\254\270\354\240\2341/\355\231\251\354\236\245\355\230\204.js" "b/live8/test84/\353\254\270\354\240\2341/\355\231\251\354\236\245\355\230\204.js" new file mode 100644 index 00000000..2d7d05cd --- /dev/null +++ "b/live8/test84/\353\254\270\354\240\2341/\355\231\251\354\236\245\355\230\204.js" @@ -0,0 +1,41 @@ +const input = require('fs') + .readFileSync(process.platform === 'linux' ? '/dev/stdin' : './input.txt') + .toString() + .trim() + .split('\n') + .map((el) => el.split(' ').map(Number)); + +function solution(input) { + const T = input[0]; + let idx = 1; + let result = []; + for (let i = 0; i < T; i++) { + const [N, M] = input[idx]; + const A = input[idx + 1]; + const B = input[idx + 2]; + A.sort((a, b) => a - b); + B.sort((a, b) => a - b); + let count = 0; + const bMaxNum = Math.max(...B); + + for (let j = 0; j < N; j++) { + if (A[j] > bMaxNum) { + count += M; + continue; + } + for (let k = 0; k < M; k++) { + if (A[j] > B[k]) count++; + else break; + } + } + result.push(count); + + idx += 3; + } + return result.join('\n'); +} + +console.log(solution(input)); + +// 노가다로 풀었더니 이진탐색이랑 4배 차이 ㄷㄷ +// 배열에서 원하값 찾을 때 이진탐색 생각하기 From 105ed24757a3dbda8185234f3ff3a30180df23bd Mon Sep 17 00:00:00 2001 From: Janghyeon Hwang <104212460+eric-hjh@users.noreply.github.com> Date: Mon, 24 Feb 2025 23:11:11 +0900 Subject: [PATCH 2/4] =?UTF-8?q?84=EC=B0=A8=202=EB=B2=88=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=ED=92=80=EC=9D=B4=EC=9D=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../\355\231\251\354\236\245\355\230\204.js" | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 "live8/test84/\353\254\270\354\240\2342/\355\231\251\354\236\245\355\230\204.js" diff --git "a/live8/test84/\353\254\270\354\240\2342/\355\231\251\354\236\245\355\230\204.js" "b/live8/test84/\353\254\270\354\240\2342/\355\231\251\354\236\245\355\230\204.js" new file mode 100644 index 00000000..4b4c8258 --- /dev/null +++ "b/live8/test84/\353\254\270\354\240\2342/\355\231\251\354\236\245\355\230\204.js" @@ -0,0 +1,14 @@ +const input = require('fs') + .readFileSync(process.platform === 'linux' ? '/dev/stdin' : './input.txt') + .toString() + .trim() + .split('\n') + .map((el) => el.split(' ').map(Number)); + +function solution(input) { + const [K, N] = input[0]; + const lanList = input.slice(1).flat(); + if (K >= N) return Math.max(...lanList); +} + +console.log(solution(input)); From e196038415d10685d8284a73a3d3bf0d49bc9772 Mon Sep 17 00:00:00 2001 From: Janghyeon Hwang <104212460+eric-hjh@users.noreply.github.com> Date: Thu, 27 Feb 2025 18:58:32 +0900 Subject: [PATCH 3/4] =?UTF-8?q?84=EC=B0=A8=202=EB=B2=88=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=ED=92=80=EC=9D=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../\355\231\251\354\236\245\355\230\204.js" | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git "a/live8/test84/\353\254\270\354\240\2342/\355\231\251\354\236\245\355\230\204.js" "b/live8/test84/\353\254\270\354\240\2342/\355\231\251\354\236\245\355\230\204.js" index 4b4c8258..38854a1f 100644 --- "a/live8/test84/\353\254\270\354\240\2342/\355\231\251\354\236\245\355\230\204.js" +++ "b/live8/test84/\353\254\270\354\240\2342/\355\231\251\354\236\245\355\230\204.js" @@ -7,8 +7,25 @@ const input = require('fs') function solution(input) { const [K, N] = input[0]; - const lanList = input.slice(1).flat(); - if (K >= N) return Math.max(...lanList); + const lanList = input.slice(1); + + let low = 1; + let high = Math.max(...lanList); + let answer = 0; + + while (low <= high) { + let mid = Math.floor((low + high) / 2); + let count = lanList.reduce((acc, cur) => acc + Math.floor(cur / mid), 0); + + if (count >= N) { + answer = mid; + low = mid + 1; + } else { + high = mid - 1; + } + } + + return answer; } console.log(solution(input)); From 167fb2f92ace129bc32f202d5069a844acc1b033 Mon Sep 17 00:00:00 2001 From: Janghyeon Hwang <104212460+eric-hjh@users.noreply.github.com> Date: Thu, 27 Feb 2025 18:59:26 +0900 Subject: [PATCH 4/4] =?UTF-8?q?84=EC=B0=A8=203=EB=B2=88=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=ED=92=80=EC=9D=B4=EC=9D=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../\355\231\251\354\236\245\355\230\204.js" | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 "live8/test84/\353\254\270\354\240\2343/\355\231\251\354\236\245\355\230\204.js" diff --git "a/live8/test84/\353\254\270\354\240\2343/\355\231\251\354\236\245\355\230\204.js" "b/live8/test84/\353\254\270\354\240\2343/\355\231\251\354\236\245\355\230\204.js" new file mode 100644 index 00000000..009132c5 --- /dev/null +++ "b/live8/test84/\353\254\270\354\240\2343/\355\231\251\354\236\245\355\230\204.js" @@ -0,0 +1,15 @@ +function solution(skill, skill_trees) { + let count = 0; + + skill_trees.forEach((tree) => { + let filtered = tree + .split('') + .filter((s) => skill.includes(s)) + .join(''); + if (skill.startsWith(filtered)) count++; + }); + + return count; +} + +console.log(solution('CBD', ['BACDE', 'CBADF', 'AECB', 'BDA']));