10000 Update 9465.cpp · urijan44/basic-algo-lecture@ae1054c · GitHub
[go: up one dir, main page]

Skip to content

Commit ae1054c

Browse files
committed
Update 9465.cpp
1 parent da886c1 commit ae1054c

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

0x10/solutions/9465.cpp

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,31 @@
1-
// Authored by : BaaaaaaaaaaarkingDog
1+
// Authored by : heheHwang
22
// Co-authored by : -
3-
// http://boj.kr/****************
3+
// http://boj.kr/6075858a4c0848a296805955dff5eb04
44
#include <bits/stdc++.h>
55
using namespace std;
66

7-
int main(void){
7+
int main(void) {
88
ios::sync_with_stdio(0);
99
cin.tie(0);
10-
10+
11+
int testCase;
12+
cin >> testCase;
13+
while (testCase--) {
14+
int N;
15+
cin >> N;
16+
vector<vector<int>> arr(N, vector<int>(2)), dp(N, vector<int>(2));
17+
for (int j = 0; j < 2; j++)
18+
for (int i = 0; i < N; i++)
19+
cin >> arr[i][j];
20+
21+
for (int i = 0; i < N; i++) {
22+
for (int j = 0; j < 2; j++) {
23+
int v = 0;
24+
if (1 < i) v = max(dp[i - 2][0], dp[i - 2][1]);
25+
if (i) v = max(v, dp[i - 1][1 - j]);
26+
dp[i][j] = v + arr[i][j];
27+
}
28+
}
29+
cout << max(dp[N - 1][0], dp[N - 1][1]) << '\n';
30+
}
1131
}

0 commit comments

Comments
 (0)
0