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; +} diff --git a/mj010504/README.md b/mj010504/README.md index f9b519f..9743e03 100644 --- a/mj010504/README.md +++ b/mj010504/README.md @@ -11,3 +11,5 @@ | 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)| | 18차시 | 2025.08.07 | 조합 | [비밀 코드 해독](https://school.programmers.co.kr/learn/courses/30/lessons/388352)|(https://github.com/AlgoLeadMe/AlgoLeadMe-15/pull/69)| + | 19차시 | 2025.08.13 | DP, 메모이제이션 | [완전 범죄](https://school.programmers.co.kr/learn/courses/30/lessons/389480)|(https://github.com/AlgoLeadMe/AlgoLeadMe-15/pull/70)| +