标签:
#include <algorithm>
#include <cstdio>
using namespace std;
typedef long long LL;
const int maxn = 1000 + 10;
LL dp[maxn];
struct pos{
int v,id;
pos(int a = -1,int b = -1):v(a),id(b){}
bool operator < (const pos & a){
return v < a.v;
}
}a[maxn];
int main(){
int n;
while(~scanf("%d",&n) && n){
int tmp;
for(int i = 1;i <= n ;++i){
scanf("%d",&tmp);
a[i] = pos(tmp,i);
}
sort(a+1,a+n+1);
LL ans = 0;
for(int i = 1;i <= n ; ++i){
dp[i] = a[i].v;
for(int j = 1;j < i;++j){
if(a[j].id < a[i].id && a[j].v < a[i].v)
dp[i] = max(dp[i] ,dp[j] + a[i].v);
}
ans = max(ans,dp[i]);
}
printf("%I64d\n",ans);
}
return 0;
}
[2016-03-27][HDU][1087][Super Jumping! Jumping! Jumping!]
标签:
原文地址:http://www.cnblogs.com/qhy285571052/p/21c77cfcbe93883b6535307714dbdaac.html