Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

이상화 / 4기 2주차 / 3문제 #134

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

이상화 / 4기 2주차 / 3문제 #134

wants to merge 3 commits into from

Conversation

idealflower-k
Copy link
Contributor

@idealflower-k idealflower-k commented Sep 12, 2024

문제명 : 호텔

시간 복잡도 : , 공간 복잡도 :

1. 풀이 과정

DP, Knapsack 문제였습니다.
dp[인원] = 비용을 의미합니다.
dp[현재인원 - 넣을 인원] + 추가비용, dp[현재인원]을 비교하며 dp 배열을 채웁니다.

문제명 : 군대탈출하기

시간 복잡도 : , 공간 복잡도 :

1. 풀이 과정

bfs로 해결하려했으나 성능개선에 문제가 있어 PerPlexity의 도움을 받았습니다.
문제의 접근방식에 전환이 필요했습니다.
레벨을 이분탐색하며 해당레벨에 골인지점에 도달할 수 있는지 BFS로 확인합니다.
최소 레벨을 찾아 결과를 출력합니다.

문제명 : 망가진 계산기

시간 복잡도 : , 공간 복잡도 :

1. 풀이 과정

일반적인 백트래킹으로 해결하면 연산이 너무 오래걸렸습니다. Perplexity의 도움으로 최적화했습니다.
1. `if (nextNum >= maxTarget) continue;`
 - 가지치기로 불필요한 연산을 줄입니다.
2. if (nextNum * Math.pow(9, operationCnt - cnt - 1) <= result) break;
- 최적화 추정 기법
- 현재 상태에서 최선의 결과와 현재 최적의해를 비교하여 불필요한 연산을 줄입니다.
3. `backTracking(cnt + 1, (int)nextNum, i); `
- 순열 생성 최적화
- (4 * 3), (3 * 4)와 같은 중복 순열 연산을 회피합니다.

@idealflower-k idealflower-k added BOJ 백준 온라인 주중에 푼 문제 labels Sep 12, 2024
@idealflower-k idealflower-k self-assigned this Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BOJ 백준 온라인 주중에 푼 문제
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant