/*********************************** Problem: HDU 2845 Beans Time: 140MS
Memory: 248K Accepted Time: 2009-08-03 20:57:11 Tip: DP
************************************/ #include <stdio.h> #define maxs(a,b)
(a>b?a:b) int main() { int dp[2],dp2[2]; int m,n,t;
while(scanf("%d%d",&m,&n)!=EOF) { int i,j,temp; dp2[0]=dp2[1]=0;
for(i=1;i<=m;i++) { dp[0]=dp[1]=0; for(j=1;j<=n;j++) { scanf("%d",&temp);
t=dp[0]; dp[0]=maxs(dp[0],dp[1]); dp[1]=t+temp; } t=dp2[0];
dp2[0]=maxs(dp2[0],dp2[1]); dp2[1]=t+maxs(dp[0],dp[1]); }
printf("%d/n",maxs(dp2[0],dp2[1])); } return 0; }
 

Technology
©2019-2020 Toolsou All rights reserved,
CSS architecture design NOI2019 travels Detailed explanation ubuntu14.04 How to set static IP2019 Year end summary —— Second year of work Big data tells you , How tired are Chinese women java Simple lottery algorithm , luck draw DemoPYTHON Summary of final review Classical algorithm - recursion ( The case of raw rabbit )2021 year 1 Monthly programmer salary statistics , average 14915 element First knowledge python Skills summary