From f657866e986196320c52f38d480046d1396b5415 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=B5=9C=EB=AF=BC=EC=A4=80?= <68235719+mj010504@users.noreply.github.com> Date: Wed, 13 Aug 2025 16:18:06 +0900 Subject: [PATCH 1/2] Update README.md --- mj010504/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mj010504/README.md b/mj010504/README.md index ec4c260..1456ea4 100644 --- a/mj010504/README.md +++ b/mj010504/README.md @@ -10,3 +10,5 @@ | 7차시 | 2025.05.20 | 분할정복 | [유전법칙](https://school.programmers.co.kr/learn/courses/15008/lessons/121685)|(https://github.com/AlgoLeadMe/AlgoLeadMe-15/pull/28)| | 8차시 | 2025.06.15 | DP | [개근상](https://www.acmicpc.net/problem/1563)|(https://github.com/AlgoLeadMe/AlgoLeadMe-15/pull/35)| | 17차시 | 2025.08.07 | BFS | [촌수 계산](https://www.acmicpc.net/problem/2644)|(https://github.com/AlgoLeadMe/AlgoLeadMe-15/pull/65)| + | 19차시 | 2025.08.13 | DP, 메모이제이션 | [완전 범죄](https://school.programmers.co.kr/learn/courses/30/lessons/389480)|(https://github.com/AlgoLeadMe/AlgoLeadMe-15/pull/70)| + From 0018ca421dc4b41275164f2c45d955a613d325d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=B5=9C=EB=AF=BC=EC=A4=80?= <68235719+mj010504@users.noreply.github.com> Date: Wed, 13 Aug 2025 16:18:40 +0900 Subject: [PATCH 2/2] =?UTF-8?q?Create=20=EC=99=84=EC=A0=84=EB=B2=94?= =?UTF-8?q?=EC=A3=84.cpp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...4\354\240\204\353\262\224\354\243\204.cpp" | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 "mj010504/Programmers/\354\231\204\354\240\204\353\262\224\354\243\204.cpp" diff --git "a/mj010504/Programmers/\354\231\204\354\240\204\353\262\224\354\243\204.cpp" "b/mj010504/Programmers/\354\231\204\354\240\204\353\262\224\354\243\204.cpp" new file mode 100644 index 0000000..3154714 --- /dev/null +++ "b/mj010504/Programmers/\354\231\204\354\240\204\353\262\224\354\243\204.cpp" @@ -0,0 +1,38 @@ +#include + +using namespace std; + + +int res = INT_MAX; +int aa, bb; + +set> check; + +void steal(vector> v, int a, int b, int i) { + if(a >= res) return; + + if (check.count(make_tuple(a, b, i))) return; + check.insert(make_tuple(a, b, i)); + + if(i == v.size()) { + res = min(res, a); + return; + } + + if(a + v[i][0] < aa) { + steal(v, a + v[i][0], b, i + 1); + } + + if(b + v[i][1] < bb) { + steal(v, a, b + v[i][1], i + 1); + } +} + +int solution(vector> v, int n, int m) { + aa = n; bb = m; + steal(v, 0, 0, 0); + + if(res == INT_MAX) res = -1; + + return res; +}