洛谷P1115——前缀和
简单dp
#include<bits/stdc++.h>
using namespace std;
#define MAXN 200005
int main(){
int n, num[MAXN], f[MAXN];
cin >> n;
for(int i = 1; i <= n; i++){
cin >> num[i];
}
int maxn = -0x3f3f3f3f;
for(int i = 1; i <= n; i++){
f[i] = max(num[i], num[i]+f[i-1]);
maxn = max(f[i], maxn);
}
cout << maxn << endl;
return 0;
}