标签:
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 30157 Accepted Submission(s): 18041
1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <algorithm> 5 #include <cmath> 6 #define Max 6000 7 using namespace std; 8 int a[Max]; 9 int dp[210][210]; 10 /*int maxx(int a,int b) 11 { 12 return a>b?a:b; 13 }*/ 14 int main() 15 { 16 int T,n,p; 17 int i,j,k; 18 freopen("in.txt","r",stdin); 19 scanf("%d",&T); 20 while(T--) 21 { 22 memset(dp,0,sizeof(dp)); 23 scanf("%d",&n); 24 p=(n+1)*n/2; 25 for(i=1;i<=p;i++) 26 scanf("%d",&a[i]); 27 for(k=n;k>=1;k--) 28 { 29 int t=(k-1+1)*(k-1)/2; 30 for(i=1;i<=k;i++) 31 dp[k][i]=max(dp[k+1][i]+a[i+t],dp[k+1][i+1]+a[i+t]); 32 } 33 printf("%d\n",dp[1][1]); 34 } 35 }
标签:
原文地址:http://www.cnblogs.com/a1225234/p/4997436.html