Skip to content

Commit e89c6ee

Browse files
committed
이슈 #418에서 솔루션 추가
1 parent 011dde6 commit e89c6ee

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

Programmers/피로도.txt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
++
2+
#include <string>
3+
#include <vector>
4+
5+
using namespace std;
6+
7+
int answer = 0;
8+
bool visited[8] = {false};
9+
10+
void dfs(int cnt, int k, vector<vector<int>> &dungeons) {
11+
if (cnt > answer) answer = cnt;
12+
13+
for (int i = 0; i < dungeons.size(); i++) {
14+
if (!visited[i] && dungeons[i][0] <= k) {
15+
visited[i] = true;
16+
dfs(cnt + 1, k - dungeons[i][1], dungeons);
17+
visited[i] = false;
18+
}
19+
}
20+
}
21+
22+
int solution(int k, vector<vector<int>> dungeons) {
23+
dfs(0, k, dungeons);
24+
25+
return answer;
26+
}

0 commit comments

Comments
 (0)