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 0adcb39 + b0df0ff commit c20d115Copy full SHA for c20d115
ksinji/202510/26 PGM 피로도.md
@@ -0,0 +1,29 @@
1
+```java
2
+class Solution {
3
+ static boolean[] visited;
4
+ static int answer = 0;
5
+
6
+ public int solution(int k, int[][] dungeons) {
7
+ visited = new boolean[dungeons.length];
8
+ dfs(k, dungeons, 0);
9
+ return answer;
10
+ }
11
12
+ static void dfs(int now, int[][] dungeons, int count) {
13
+ if (count > answer) answer = count;
14
15
+ for (int i = 0; i < dungeons.length; i++) {
16
+ if (visited[i]) continue;
17
18
+ int need = dungeons[i][0];
19
+ int cost = dungeons[i][1];
20
21
+ if (now >= need) {
22
+ visited[i] = true;
23
+ dfs(now - cost, dungeons, count + 1);
24
+ visited[i] = false;
25
26
27
28
+}
29
+```
0 commit comments