function solution(k, dungeons) {
var answer = 0;
// visited
let visited=Array.from({length:dungeons.length}, ()=>[false]);
const DFS=(hp, level)=>{
for (let i=0;i<dungeons.length;i++){
if (!visited[i] && dungeons[i][0]<=hp){
visited[i]=true;
DFS(hp-dungeons[i][1], level+1);
visited[i]=false;
}
}
answer=Math.max(answer,level);
}
DFS(k,0);
return answer;
}