标签:style blog http color os io
求递增子序列的最大和,没什么好说的。
粗暴1A,嘎嘎!
1 //#define LOCAL 2 #include <iostream> 3 #include <cstdio> 4 #include <cstring> 5 #include <algorithm> 6 using namespace std; 7 8 int a[1010]; 9 int dp[1010]; 10 11 int main(void) 12 { 13 #ifdef LOCAL 14 freopen("1087in.txt", "r", stdin); 15 #endif 16 17 int n; 18 while(scanf("%d", &n) && n) 19 { 20 int i; 21 for(i = 0; i < n; ++i) 22 { 23 scanf("%d", &a[i]); 24 dp[i] = a[i]; 25 } 26 27 for(i = 1; i < n; ++i) 28 for(int j = 0; j < i; ++j) 29 { 30 if(a[j] < a[i]) 31 dp[i] = max(dp[i], dp[j] + a[i]); 32 } 33 34 int ans = a[0]; 35 for(i = 1; i < n; ++i) 36 ans = max(ans, dp[i]); 37 printf("%d\n", ans); 38 } 39 return 0; 40 }
HDU 1087 Super Jumping! Jumping! Jumping!,布布扣,bubuko.com
HDU 1087 Super Jumping! Jumping! Jumping!
标签:style blog http color os io
原文地址:http://www.cnblogs.com/AOQNRMGYXLMV/p/3864217.html