일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- 프로그래머스 레벨 2
- 문자열
- 그래프
- 쉬운 문제
- 타입스크립트
- javascript
- 자바스크립트
- 레벨 1
- HTTP 완벽 가이드
- HTTP
- Algorithm
- socket
- 타입 챌린지
- ip
- 백준
- BFS
- 프로그래머스
- 가천대
- Crawling
- TCP
- dp
- 크롤링
- 소켓
- Nestjs
- Node.js
- type challenge
- 수학
- typescript
- 알고리즘
- dfs
- Today
- Total
목록다이나믹 프로그래밍 (6)
kakasoo

꽤 어려웠다. // 백준 14501번 퇴사 문제를 풀었습니다. const readline = require("readline"); const rl = readline.createInterface({ input: process.stdin, output: process.stdout, }); let count = 0; const input = []; rl.on("line", (line) => { if (count === 0) { count = Number(line); } else { input.push(line); if (input.length === count) { main(); rl.close(); } } }).on("close", () => { process.exit(); }); const main = ..

const readline = require("readline"); const rl = readline.createInterface({ input: process.stdin, output: process.stdout, }); rl.on("line", (line) => { main(line); rl.close(); }).on("close", () => process.exit()); /** * * @param {string} line */ const main = (line) => { const [N, K] = line.split(" ").map(Number); const DP = new Array(K + 1).fill(0); // DP[k][N] : k개로 N을 만드는 경우의 수 for (let i = 0; i

요즘 DP 문제만 주구장창 풀고 있는데, DP를 푸는 요령은 이렇다. 먼저 DP[n]이 의미하는 것이 무엇인지 찾는다. 이 문제에는 DP[n]의 정의는, n을 만들기 위해서 필요한 최소 제곱수 항이었다. DP[n]을 그러면 숫자들의 나열로 생각한다. ( 이 문제는 합이기 때문에 덧셈의 나열로 생각하면 된다. ) 거기서 마지막이 무엇인지 생각한다. 이 문제에서는 당연히, n의 제곱근이 될 것이다. 그렇다면 우리가 알 수 있는 게 생긴다. DP[n - 마지막 값의 제곱] + 1이 DP[n]이라는 점화식이다. const readline = require("readline"); const rl = readline.createInterface({ input: process.stdin, output: process..

const readline = require("readline"); const rl = readline.createInterface({ input: process.stdin, output: process.stdout, }); let count = 0; rl.on("line", (line) => { if (!count) { count = Number(line); } else { main(line); rl.close(); } }).on("close", () => process.exit()); /** * * @param {string} line */ const main = (line) => { const numbers = line.split(" ").map(Number); const DP1 = [numbers..

const readline = require("readline"); const rl = readline.createInterface({ input: process.stdin, output: process.stdout, }); let count = 0; rl.on("line", (line) => { if (!count) { count = Number(line); } else { main(line); } }); /** * * @param {string} line */ const main = (line) => { const numbers = line.split(" ").map(Number); const DP = new Array(numbers.length).fill(0); for (let i = 0; i < ..

문제 자체는 어렵지 않다, 떠올리는 발상이 좀 오래 걸릴 수 있긴 하지만, 생각을 해냈다면 그 이후는 크게 어려울 것도 없다. 나 같은 경우에는, 하나의 index를 기준으로 좌측과 우측으로 각각 내림차순으로 최장 길이 수열을 구하고, 그 둘의 합을 하나의 dp에 저장할 것이다. 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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 #include using namespace std; int list[1000]; int dp[1000][3]; int n; int main(void) { cin >> n; for..