This question did not write the problem at that time, this is a water DP bar
I'll give you a 2*n lattice, and then you can't take the next side of the stamp.
Then the current turntable can only be launched from the upper left and left corner of its own front, and finally the first and second rows to get the maximum value
#include <cstdio>#include <cstring>#include <algorithm>using namespace STD;intdp[2][111111];inta[2][111111];intNintMain () {intTscanf("%d", &t); while(t--) {scanf("%d", &n); for(intj=0; j<=1; j + +) for(intI=1; i<=n;i++) {scanf("%d", &a[j][i]); }memset(DP,0,sizeof(DP)); dp[0][1]=a[0][1]; dp[1][1]=a[1][1]; a[0][0]=0; a[1][0]=0; for(intI=2; i<=n;i++) {dp[1][i]=max (dp[1][i],dp[0][i-1]+a[1][i]); dp[1][i]=max (dp[1][i],dp[0][i-2]+a[1][i]); dp[0][i]=max (dp[0][i],dp[1][i-1]+a[0][i]); dp[0][i]=max (dp[0][i],dp[1][i-2]+a[0][i]); }printf("%d\n", Max (dp[0][n],dp[1][n])); }}
Copyright notice: All brothers, please feel free to reprint, please indicate who is the brother
Uvalive 6510 Stickers