Skip to content

피로도 #418

@fkdl0048

Description

@fkdl0048
#include <string>
#include <vector>

using namespace std;

int answer = 0;
bool visited[8] = {false};

void dfs(int cnt, int k, vector<vector<int>> &dungeons) {
    if (cnt > answer) answer = cnt;
    
    for (int i = 0; i < dungeons.size(); i++) {
        if (!visited[i] && dungeons[i][0] <= k) {
            visited[i] = true;
            dfs(cnt + 1, k - dungeons[i][1], dungeons);
            visited[i] = false;
        }
    }
}

int solution(int k, vector<vector<int>> dungeons) {
    dfs(0, k, dungeons);
    
    return answer;
}

Metadata

Metadata

Assignees

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions