-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathLv2_피로도.cpp
More file actions
34 lines (27 loc) · 759 Bytes
/
Lv2_피로도.cpp
File metadata and controls
34 lines (27 loc) · 759 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <string>
#include <vector>
#include <iostream>
using namespace std;
int answer;
void dfs(int hp, int cnt, vector<bool> check, vector<vector<int>> dungeons) {
if (answer < cnt)
answer = cnt;
for (int i = 0; i < dungeons.size(); ++i) {
if (!check[i] && hp >= dungeons[i][0]) {
check[i] = true;
dfs(hp - dungeons[i][1], cnt + 1, check, dungeons);
check[i] = false;
}
}
}
int solution(int k, vector<vector<int>> dungeons) {
vector<bool> check(dungeons.size(), false);
dfs(k, 0, check, dungeons);
return answer;
}
int main() {
int k = 80;
vector<vector<int>> dungeons = {{80, 20}, {50, 40}, {30, 10}};
cout << solution(k, dungeons);
return 0;
}