Skip to content

Commit 672c006

Browse files
committed
[20251109] PGM / LV2 / 피로도 / 김민진
1 parent 3ebe85f commit 672c006

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
```java
2+
public class PGM_LV2_피로도 {
3+
4+
private static int N, ans;
5+
private static boolean[] visited;
6+
private static int[][] dungeons;
7+
8+
private static void init(int[][] d) {
9+
N = d.length;
10+
ans = 0;
11+
dungeons = d;
12+
visited = new boolean[N];
13+
}
14+
15+
private static void sol(int depth, int stamina, int cnt) {
16+
ans = Math.max(ans, cnt);
17+
18+
for (int i = 0; i < N; i++) {
19+
if (visited[i] || stamina < dungeons[i][0]) continue;
20+
21+
visited[i] = true;
22+
sol(depth + 1, stamina - dungeons[i][1], cnt + 1);
23+
visited[i] = false;
24+
}
25+
}
26+
27+
public int solution(int k, int[][] d) {
28+
init(d);
29+
sol(0, k, 0);
30+
31+
return ans;
32+
}
33+
}
34+
```

0 commit comments

Comments
 (0)