땅따먹기 (1) 썸네일형 리스트형 [프로그래머스] (C++) 땅따먹기 문제는 이 주소로 가면 있습니다. 처음에 저는 아래와 같은 코드로 문제를 푸려고 하였습니다. #include #include using namespace std; vector gLand; int gMax; void getTotal(int cur, int last, int n, int total) { if (cur == n) { if (gMax < total) gMax = total; return; } for (int i = 0; i < 4; i++) { if (last != i) { getTotal(cur+1, i, n, total + gLand[cur][last]); } } } int solution(vector land) { gLand = land; for (int i = 0; i < 4; i++) .. 이전 1 다음