求LIS 并使得路径上合最大
维护个dp即可
#include <bits/stdc++.h>
using namespace std;
int num[1000];
int DP[1000];
int main()
{
int N;
scanf("%d",&N);
while (N != 0){
num[0] = 0;
memset(DP,0,sizeof DP);
for (int i = 1;i<=N;i++){
scanf("%d",&num[i]);
}
int m = 0;
for (int i = 1;i<=N;i++){
for (int j = 0;j<i;j++){
if (num[j] < num[i])
DP[i] = max(DP[j]+num[i],DP[i]);
}
m = max(DP[i],m);
}
cout<<m<<endl;
scanf("%d",&N);
}
return 0;
}