Programmers 87946
피로도


CODE ⌨️

#include <string>
#include <vector>
#include <algorithm>

using namespace std;

bool visited[8];

int result = 0;

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

int solution(int k, vector<vector<int>> dungeons)
{
    int answer = -1;
    
    DFS(k, 0, dungeons);
    
    answer = result;
    
    return answer;
}



RESULT 💛



SIMPLE DISCUSSION ✏️

완전탐색 문제였다.



SOURCE 💎

Programmers_Link 👈 Click here


*****
NOT A TALENT ❎ NOT GIVING UP ✅
CopyRight ⓒ 2022 DCherish All Rights Reserved.