跳到正文

MINECRAFT20150201

2029070

此生无悔入MC,来世还做方块人!团宣https://www.luogu.com.cn/team/135956

在洛谷打开
资料、奖项与版本

资料

编号
2029070
抓取

https://i1.hdslb.com/bfs/archive/03be745a4fe23e98a8283d01cd9bb966a5c82c0e.jpg #include<bits/stdc++.h> using namespace std; int a[1005],s[1005]; int main() { int i,j,n,maxn=0,max1=0; cin>>n; for(i=1;i<=n;i++) { cin>>a[i]; } s[1]=a[1]; for(i=2;i<=n;i++) { maxn=0; for(int j=1;j<=i-1;j++) { if(a[j]<a[i]) { if(s[j]>maxn) { maxn=s[j]; } } } s[i]=maxn+a[i]; } for(i=1;i<=n;i++) { if(s[i]>max1) { max1=s[i]; } } cout<<max1; }

还没有收录这位用户的文章。