Super Jumping! Jumping! Jumping!-HDU1087
求上升子序列的和的最大值
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define int long long
int sum,n;
int x[1005],dp[1005];
void solve(){
sum = 0;
for(int i = 1;i <= n;++i){
cin>>x[i];
dp[i] = x[i];
for(int j = 1;j < i;++j)
if(x[j] < x[i])
dp[i] = max(dp[i],x[i] + dp[j]);
sum = max(sum,dp[i]);
}
cout<<sum<<"\n";
}
signed main(){
IOS;
while(cin>>n && n != 0)
solve();
return 0;
}