목록백준 (31)
이우의 개발일지

백준 1149번 RGB 거리 #include#includeusing namespace std;int d[1001][4];int main() { int n; cin >> n; vector> vec; int r[1000]; int b[1000]; int g[1000]; for (int i = 1; i > r[i] >> b[i] >> g[i]; d[1][0] = r[1]; d[1][1] = g[1]; d[1][2] = b[1]; for (int i = 2; i

백준 2579번 계단 오르기https://www.acmicpc.net/problem/2579 이번 계단 오르기 문제는 2차 배열을 이용해 풀었다.전에 풀었던 DP 문제에서 세번째 연속되면 안되는 조건이 추가되어, 그 조건을 컨트롤하는데 추가 배열이 필요했다. (D[300][3]으로 설정해줘도 됨.) d[i][1] -> 전 계단을 건너뛰고 밟은 i 번째 계단d[i][2] -> 전 계단을 밟고 두번 연속되게 밟은 i 번째 계단(d[i][2]일 때는 무조건 d[i-1][1]을 밟았다고 해야됨 & 다음 계단은 무조건 건너뛰어야됨) 이라는 조건이 붙는다. 여기서 내가 간과한 점:d[i][1] = max(d[i - 2][1], d[i - 2][2]) + vec[i];당연히 d[i-2][2] 가 d[i-2][1]보..

백준 9095번 1,2,3 더하기 이번 문제는 DP를 잘쓰냐를 확인하는 문제이다.DP 의 중요한 점은 테이블과 점화식 세우기이다.이 규칙을 잘 파악할 수 있으면 금방 풀 수 있을 것이다. #include#includeusing namespace std;int d[10000005];int main() { int t; cin >> t; vector vec; for (int i = 0; i > num; vec.push_back(num); } d[1] = 1; d[2] = 2; d[3] = 4; for (int i = 4; i