We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e0168ab commit e09b54aCopy full SHA for e09b54a
1 file changed
LiiNi-coder/202511/30 BOJ 캡틴 이다솜.md
@@ -0,0 +1,35 @@
1
+```java
2
+import java.io.*;
3
+import java.util.*;
4
+
5
+public class Main {
6
+ public static void main(String[] args) throws IOException {
7
+ BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
8
+ int N = Integer.parseInt(br.readLine());
9
+ List<Integer> tetra = new ArrayList<>();
10
+ for(int k=1; ; k++){
11
+ // 총알 개수
12
+ int t = k * (k + 1) * (k + 2) / 6;
13
+ if(t > N)
14
+ break;
15
+ tetra.add(t);
16
+ }
17
+ int size = tetra.size();
18
19
20
+ int[] dp = new int[N + 1];
21
+ Arrays.fill(dp, Integer.MAX_VALUE);
22
+ dp[0] = 0;
23
+ for(int i = 0; i < size; i++){
24
+ int t = tetra.get(i);
25
+ for(int x = t; x <= N; x++){
26
+ if(dp[x - t] != Integer.MAX_VALUE){
27
+ dp[x] = Math.min(dp[x], dp[x-t] + 1);
28
29
30
31
+ System.out.println(dp[N]);
32
33
+}
34
35
+```
0 commit comments