标签:
#include <cstdio> #include <iostream> #include <sstream> #include <string> #include <cstring> #include <algorithm> #include <cmath> #include <queue> #include <vector> #define PI acos(-1.0) #define ms(a) memset(a,0,sizeof(a)) #define msp memset(mp,0,sizeof(mp)) #define msv memset(vis,0,sizeof(vis)) #define msd memset(dp,0,sizeof(dp)) using namespace std; //#define LOCAL int dp[1001]; int a[1001]; int main() { #ifdef LOCAL freopen("in.txt", "r", stdin); //freopen("out.txt","w",stdout); #endif // LOCAL ios::sync_with_stdio(false); int n; while(cin>>n&&n) { msd,ms(a); for(int i=1; i<=n; i++) cin>>a[i]; for(int i=1; i<=n; i++) { int ans=-999999999; for(int j=0; j<i; j++) { if(a[i]>a[j]) ans=max(ans,dp[j]); } dp[i]=ans+a[i]; } int ans=-999999999; for(int i=0;i<=n;i++) ans=max(ans,dp[i]); printf("%d\n",ans); } return 0; }
Super Jumping! Jumping! Jumping!
标签:
原文地址:http://www.cnblogs.com/gpsx/p/5216535.html