링크 : https://school.programmers.co.kr/learn/courses/30/lessons/87946
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int solution(int k, vector<vector<int>> dungeons) {
int answer = 0;
vector<int> v;
for(int i = 0; i < dungeons.size(); i++){
v.push_back(i);
}
do{
int temp = k;
int cnt = 0;
for(int i = 0; i < v.size(); i++){
int min = dungeons[v[i]][0];
int used = dungeons[v[i]][1];
if (min > temp) continue;
temp -= used;
cnt ++;
}
answer = max(answer, cnt);
} while(next_permutation(v.begin(), v.end()));
return answer;
}