Skip to content

Commit

Permalink
Merge branch 'main' into 13-pu2rile
Browse files Browse the repository at this point in the history
  • Loading branch information
pu2rile committed Sep 4, 2024
2 parents 8f0143e + 51a4e84 commit bd61bc9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pu2rile/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

| μ°¨μ‹œ | λ‚ μ§œ | λ¬Έμ œμœ ν˜• | 링크 | 풀이 |
|:----:|:---------:|:----:|:-----:|:----:|
| 1μ°¨μ‹œ | 2024.03.24 | DP | [ν‰λ²”ν•œ λ°°λ‚­](https://www.acmicpc.net/problem/12865) | [#3](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/3#issue-2205834078)|
| 1μ°¨μ‹œ | 2024.03.24 | 동적 ν”„λ‘œκ·Έλž˜λ° | [ν‰λ²”ν•œ λ°°λ‚­](https://www.acmicpc.net/problem/12865) | [#3](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/3#issue-2205834078)|
| 2μ°¨μ‹œ | 2024.03.29 | κ΅¬ν˜„ | [OXν€΄μ¦ˆ](https://www.acmicpc.net/problem/8958) | [#6](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/6#issue-2214931034)|
| 3μ°¨μ‹œ | 2024.04.02 | λ¬Έμžμ—΄ | [ν¬λ‘œμ•„ν‹°μ•„ μ•ŒνŒŒλ²³](https://www.acmicpc.net/problem/8958) | [#10](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/10#issue-2220631332)
| 4μ°¨μ‹œ | 2024.04.08 | μŠ€νƒ | [제둜](https://www.acmicpc.net/problem/10773) | [#15](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/15#issue-2229909173)
Expand All @@ -14,4 +14,4 @@
| 10μ°¨μ‹œ | 2024.07.11 | μŠ€νƒ | [ν™”ν•™μ‹λŸ‰](https://www.acmicpc.net/problem/2257) | [#35](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/35#issue-2403173169)
| 11μ°¨μ‹œ | 2024.07.13 | μš°μ„ μˆœμœ„ 큐 | [κ°•μ˜μ‹€](https://www.acmicpc.net/problem/1374) | [#37](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/37#issue-2406937336)
| 12μ°¨μ‹œ | 2024.07.23 | 동적 ν”„λ‘œκ·Έλž˜λ° | [1ν•™λ…„](https://www.acmicpc.net/problem/5557) | [#40](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/40)
| 13μ°¨μ‹œ | 2024.07.26 | μŠ€νƒ | [ν›„μœ„ ν‘œκΈ°μ‹](https://www.acmicpc.net/problem/1918) | [#43](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/43)
| 13μ°¨μ‹œ | 2024.07.26 | μŠ€νƒ | [ν›„μœ„ ν‘œκΈ°μ‹](https://www.acmicpc.net/problem/1918) | [#43](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/43)
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
n = int(input())
nums = list(map(int, input().split()))

# dp ν…Œμ΄λΈ” μ΄ˆκΈ°ν™”
dp = [[0] * 21 for _ in range(n)] # 0 이상 20 μ΄ν•˜μΈ μˆ«μžμ΄λ―€λ‘œ 크기가 21인 λ°°μ—΄

# 첫 번째 숫자λ₯Ό dp ν…Œμ΄λΈ”μ— μ΄ˆκΈ°κ°’μœΌλ‘œ μ„€μ •
dp[0][nums[0]] = 1

# dp ν…Œμ΄λΈ” μ±„μš°κΈ°
for i in range(1, n - 1):
for j in range(21):
if dp[i - 1][j]:
if j + nums[i] <= 20: # λ”ν•˜κΈ°
dp[i][j + nums[i]] += dp[i - 1][j]
if j - nums[i] >= 0: # λΉΌκΈ°
dp[i][j - nums[i]] += dp[i - 1][j]

# λ§ˆμ§€λ§‰ 숫자λ₯Ό λͺ©ν‘œ κ°’μœΌλ‘œ λ§Œλ“€ 수 μžˆλŠ” 경우의 수 좜λ ₯
print(dp[n-2][nums[-1]])

0 comments on commit bd61bc9

Please sign in to comment.