Replies: 1 comment 1 reply
-
이 태그를 쓰면 시간복잡도 표현 가능합니당. N2 |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
문제
https://www.acmicpc.net/problem/1182
아이디어
N개의 정수를 중복을 허용하지 않고 합이 S가 되는 크기가 양수인 부분수열을 구하는 문제다.
1~N 크기의 부분수열을 전부 완전탐색으로 구해서 합이 S가 되는 경우를 찾으면 되겠다!!!
부분 수열은 중복을 허용하지 않고 순서도 고려하지 않기 때문에 백트래킹으로 조합구하듯이 풀면 될 거 같다.
시간 복잡도
조합의 시간 복잡도는 O(2N)이고 N번 도는 for문 안에 있으니까 총 O(N*2N)
N의 최댓값이 20이므로 20 * 220 < 2초 라서 가능한 풀이법이다.
Beta Was this translation helpful? Give feedback.
All reactions