乱写
2023-07-09 15:07:45
发布于:广东
11阅读
0回复
0点赞
#include <bits/stdc++.h>
using namespace std;
const unsigned MAX = 1e3+5;
unsigned n,a[MAX],dp[MAX],maxx;
int main(){
cin>>n;
for (int i=0;i<n;i++) cin>>a[i];
for (int i=0;i<n;i++){
maxx=a[i];
for (int j=0;j<i;j++){
if (a[j]<a[i]) maxx = max(maxx,a[i]+dp[j]);
}
dp[i] = maxx;
}
maxx = dp[0];
for (int i=0;i<n;i++) maxx = max(maxx,dp[i]);
cout<<maxx;
return 0;
}
这里空空如也
有帮助,赞一个