标签:des style blog http color java os io
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2637 Accepted Submission(s): 1302
1 #include<cstdio> 2 #include<cstring> 3 #include<stdlib.h> 4 #include<algorithm> 5 using namespace std; 6 int a[200005],dp[200005]; 7 int main() 8 { 9 int n,m,i,j; 10 while(scanf("%d %d",&n,&m)!=EOF) 11 { 12 for(i=1;i<=n;i++) 13 { 14 for(j=1;j<=m;j++) 15 scanf("%d",&a[j]); 16 for(j=2;j<=m;j++) 17 a[j]=max(a[j-1],a[j-2]+a[j]); 18 dp[i]=a[m]; 19 } 20 for(i=2;i<=n;i++) 21 dp[i]=max(dp[i-2]+dp[i],dp[i-1]); 22 printf("%d\n",dp[n]); 23 } 24 return 0; 25 }
HDU 2845 Beans (最大不连续子序列和),布布扣,bubuko.com
标签:des style blog http color java os io
原文地址:http://www.cnblogs.com/clliff/p/3894134.html