-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEDPC_C.cpp
More file actions
44 lines (39 loc) · 768 Bytes
/
EDPC_C.cpp
File metadata and controls
44 lines (39 loc) · 768 Bytes
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
42
43
44
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T>
inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
int N;
long long a[100010][3];
// DPテーブル
long long dp[100010][3];
int main() {
scanf("%d", &N);
for (int i = 0; i < N; i++) {
for (int j = 0; j < 3; j++) cin >> a[i][j];
}
for (int i = 0; i < N; ++i) {
for (int j = 0; j < 3; ++j) {
for (int k = 0; k < 3; ++k) {
if (j == k) continue;
chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
}
}
}
long long ans = 0;
for (int j = 0; j < 3; ++j) chmax(ans, dp[N][j]);
printf("%lld", ans);
}