#include <iostream>
using namespace std;
int cost[1000][3];
long long costDP[1000][2];
void makeDP(int N)
{
costDP[0][0] = cost[0][0];
costDP[0][1] = cost[0][1];
costDP[0][2] = cost[0][2];
for (int i = 1; i < N; i++)
{
costDP[i][0] = min(costDP[i - 1][1], costDP[i - 1][2]) + cost[i][0];
costDP[i][1] = min(costDP[i - 1][0], costDP[i - 1][2]) + cost[i][1];
costDP[i][2] = min(costDP[i - 1][0], costDP[i - 1][1]) + cost[i][2];
}
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
int N;
cin >> N;
for (int i = 0; i < N; i++)
{
cin >> cost[i][0] >> cost[i][1] >> cost[i][2];
}
makeDP(N);
long long result =
min(costDP[N - 1][0], costDP[N - 1][1]) > costDP[N - 1][2] ? costDP[N - 1][2] : min(costDP[N - 1][0], costDP[N - 1][1]);
cout << result;
}
'๐ก๐ธ๐ธ๐ถ๐ฃ: ๐๐๐๐๐๐พ๐๐ฝ๐ > ์๊ณ ๋ฆฌ์ฆ ๋ฌธ์ ํ์ด' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
BOJ 2503 : ์ซ์์ผ๊ตฌ (Silver 5) (0) | 2021.08.20 |
---|---|
BOJ17404 : RGB๊ฑฐ๋ฆฌ2 (Gold 4) (0) | 2021.08.17 |
BOJ11660 : ๊ตฌ๊ฐ ํฉ ๊ตฌํ๊ธฐ 5 (Silver 1) (0) | 2021.08.15 |
BOJ2012 : ๋ฑ์๋งค๊ธฐ๊ธฐ (Silver 3) (0) | 2021.08.13 |
BOJ1343 : ํด๋ฆฌ์ค๋ฏธ๋ ธ (Silver 5) (0) | 2021.08.13 |