-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path1149.cpp
41 lines (34 loc) · 966 Bytes
/
1149.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <functional>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#define xx first
#define yy second
#define all(x) (x).begin(), (x).end()
#define MAXN 1e6
using namespace std;
using i64 = long long;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;
int main() {
int n;
scanf("%d", &n);
vector<vector<int> > v(n + 5, vector<int>(3, 0));
for (int i = 1; i <= n; i++)
scanf("%d %d %d", &v[i][0], &v[i][1], &v[i][2]);
vector<vector<int> > count(n + 5, vector<int>(3, 0));
for (int i = 1; i <= n; i++)
{
count[i][0] = min(count[i - 1][1], count[i - 1][2]) + v[i][0];
count[i][1] = min(count[i - 1][0], count[i - 1][2]) + v[i][1];
count[i][2] = min(count[i - 1][1], count[i - 1][0]) + v[i][2];
}
printf("%d\n", min({ count[n][0], count[n][1], count[n][2] }));
return 0;
}