문제 URL : https://school.programmers.co.kr/learn/courses/15008/lessons/121684
프로그래머스
SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프
programmers.co.kr
문제 접근법 :
전수 조사 문제이고 백트래킹을 이용해서 모든 경우의수를 구해 가장 최대값을 찾으면 되는문제입니다.
소스코드 :
#include<bits/stdc++.h>
using namespace std;
vector<vector<int>> arr;
vector<int>check;
int n,m;
int dfs(int h){
if(h>=m){
return 0;
}
int res =0;
for(int i=0;i<n;i++){
if(check[i]==0){
check[i]=1;
res = max(res,dfs(h+1)+arr[i][h]);
check[i]=0;
}
}
return res;
}
int solution(vector<vector<int>> ability) {
int answer = 0;
n = ability.size();
m = ability[0].size();
arr = ability;
check = vector<int>(n);
return dfs(0);
}
궁금한점이나 모르는점 어떤 질문이든 댓글은 언제나 환영입니다.
'프로그래머스' 카테고리의 다른 글
프로그래머스 pccp 모의고사 1-4 운영체제 (0) | 2024.12.01 |
---|---|
프로그래머스 pccp 모의고사 1-3 유전법칙 (0) | 2024.12.01 |
프로그래머스 pccp 모의고사 1-1 외톨이 알파벳 (0) | 2024.12.01 |
프로그래머스 [PCCP 기출문제] 4번 / 수식 복원하기 (0) | 2024.10.22 |
프로그래머스 [PCCP 기출문제] 3번 / 충돌위험 찾기 (0) | 2024.10.22 |