We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 43523ac + 672c006 commit 13bc04eCopy full SHA for 13bc04e
zinnnn37/202511/9 PGM LV2 던전.md
@@ -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