맛있는감귤

BOJ : 1149 RGB거리 본문

알고리즘/백준 알고리즘

BOJ : 1149 RGB거리

맛있는감귤 2017. 1. 12. 18:01

문제 : https://www.acmicpc.net/problem/1149


github : https://github.com/JEONG-SEUNGWOOK/BOJ/blob/master/1149.cpp


DP 문제


#include <stdio.h>
#include <algorithm>
using namespace std;

int N;
int main(){
    scanf("%d",&N);
    
    int a, b, c;
    int temp_a, temp_b, temp_c;
    scanf("%d %d %d",&a, &b, &c);
    for(int i=0;i<N-1;i++){
        scanf("%d %d %d",&temp_a, &temp_b, &temp_c);
        temp_a += min(b, c);
        temp_b += min(c, a);
        temp_c += min(a, b);
        
        a=temp_a;
        b=temp_b;
        c=temp_c;
    }
    printf("%d",min(min(a,b),c));
    
    return 0;
}

'알고리즘 > 백준 알고리즘' 카테고리의 다른 글

BOJ : 1158 조세퍼스 문제  (0) 2017.01.15
BOJ : 2276 암기왕  (0) 2017.01.12
BOJ : 1094 막대기  (0) 2017.01.12
BOJ : 1085 직사각형에서 탈출  (0) 2017.01.12
BOJ : 1026 보물  (0) 2017.01.12