File tree Expand file tree Collapse file tree 1 file changed +24
-4
lines changed Expand file tree Collapse file tree 1 file changed +24
-4
lines changed Original file line number Diff line number Diff line change 1
- // Authored by : BaaaaaaaaaaarkingDog
1
+ // Authored by : heheHwang
2
2
// Co-authored by : -
3
- // http://boj.kr/****************
3
+ // http://boj.kr/6075858a4c0848a296805955dff5eb04
4
4
#include < bits/stdc++.h>
5
5
using namespace std ;
6
6
7
- int main (void ){
7
+ int main (void ) {
8
8
ios::sync_with_stdio (0 );
9
9
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
+ }
11
31
}
You can’t perform that action at this time.
0 commit comments