#include <bits/stdc++.h> #define pb push_back #define _for(i,a,b) for(int i = (a);i < (b);i ++) #define INF 0x3f3f3f3f #define sz size() using namespace std; const int maxn = 50003; typedef long long ll; int main() { int T; while(scanf("%d",&T) && T!=0) { int a[T]; int dp[T]; _for(i,0,T) scanf("%d",&a[i]); _for(i,0,T) dp[i] = a[i]; dp[0] = a[0]; _for(i,1,T) { _for(j,0,i) if(a[i]>a[j]) dp[i] = max(dp[i],dp[j]+a[i]); } int rnt = INT_MIN; _for(i,0,T) rnt = max(rnt,dp[i]); cout << rnt << endl; } return 0; }
垃圾题,对于都是负数的情况,居然不是输出0,题干简直形同虚设