Skip to content

Commit

Permalink
2025-01-31
Browse files Browse the repository at this point in the history
  • Loading branch information
g0rnn committed Jan 31, 2025
1 parent 3cc8431 commit 029f8f8
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
4 changes: 4 additions & 0 deletions g0rnn/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
| 11์ฐจ์‹œ | 2024.12.30 | dp | [๊ธฐํƒ€๋ฆฌ์ŠคํŠธ](https://www.acmicpc.net/problem/1495) | https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/49 |
| 12์ฐจ์‹œ | 2025.01.02 | bfs | [ํšŒ์žฅ๋ฝ‘๊ธฐ](https://www.acmicpc.net/problem/2660) | https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/50 |
| 13์ฐจ์‹œ | 2025.01.05 | ๋ฐฑํŠธ๋ž˜ํ‚น | [์Šคํƒ€ํŠธ์™€ ๋งํฌ](https://www.acmicpc.net/problem/14889) | https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/52 |
| 14์ฐจ์‹œ | 2025.01.07 | ๋ฐฑํŠธ๋ ˆํ‚น | [N-Queen](https://www.acmicpc.net/problem/9663) | https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/53 |
| 15์ฐจ์‹œ | 2025.01.05 | ๋ฐฑํŠธ๋ž˜ํ‚น | [์•ŒํŒŒ๋ฒณ](https://www.acmicpc.net/problem/1987) | https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/60 |
| 16์ฐจ์‹œ | 2025.01.18 | ๋‹ค์ต์ŠคํŠธ๋ผ | [์ตœ๋‹จ๊ฒฝ๋กœ](https://www.acmicpc.net/problem/1753) | https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/62 |
| 17์ฐจ์‹œ | 2025.01.31 | dp | [์„คํƒ• ๋ฐฐ๋‹ฌ](https://www.acmicpc.net/problem/2839) | https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/68 |


---
24 changes: 24 additions & 0 deletions g0rnn/dp/Sol2839.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import java.util.*;

public class Sol2839 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);

int n = sc.nextInt();

int[] dp = new int[5001];

dp[0] = dp[1] = dp[2] = dp[4] = Integer.MAX_VALUE;
dp[3] = 1;
dp[5] = 1;

for(int i = 6; i <= n; i++) {
if(dp[i-3] == Integer.MAX_VALUE && dp[i-5] == Integer.MAX_VALUE)
dp[i] = Integer.MAX_VALUE;
else
dp[i] = Integer.min(dp[i-3], dp[i-5]) + 1;
}
System.out.println((dp[n] == Integer.MAX_VALUE) ? -1 : dp[n]);
sc.close();
}
}

0 comments on commit 029f8f8

Please sign in to comment.