Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
Tags
- 프로그래머스
- SQL
- COS PRO
- 이분탐색
- 러닝일지
- math
- BOJ
- oracle
- 자바
- 시뮬레이션
- BFS
- binary search
- Java
- 코테
- greedy
- db
- priorityqueue
- 백준
- SWEA
- DP
- 건강
- 코딩테스트
- dfs
- 투포인터
- MySQL
- 문제풀이
- 문자열
- 문제해결
- 운동기록
- 알고리즘
Archives
- Today
- Total
슈콩
[프로그래머스] Lv.2 피로도 본문


[문제]
https://school.programmers.co.kr/learn/courses/30/lessons/87946#qna
프로그래머스
SW개발자를 위한 평가, 교육의 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프
programmers.co.kr
[소스 코드]
class Solution {
int n,answer;
boolean[] visit;
public int solution(int k, int[][] dungeons) {
answer = -1;
n = dungeons.length;
visit = new boolean[n];
count(0,k,dungeons);
return answer;
}
private void count(int cnt,int sum,int[][] dungeons){
answer = Math.max(answer,cnt);
for(int i=0;i<n;i++){
if(!visit[i] && dungeons[i][0]<=sum){
visit[i] = true;
count(cnt+1,sum-dungeons[i][1],dungeons);
visit[i] = false;
}
}
}
}'Algorithms > Programmers' 카테고리의 다른 글
| [프로그래머스] Lv.2 [1차] 캐시 (0) | 2025.10.15 |
|---|---|
| [프로그래머스] Lv.2 기능개발 (0) | 2025.10.15 |
| [프로그래머스] Lv.2 의상 (0) | 2025.10.15 |
| [프로그래머스] Lv.2 괄호 회전하기 (0) | 2025.10.14 |
| [프로그래머스] Lv.2 할인 행사 (0) | 2025.10.14 |