文章
99
粉丝
120
获赞
8
访问
96.9k
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
using namespace std;
int dp[1000010];
int a[1000010];
long long maxx;
int main()
{
int n;
while (cin >> n)
{
for (int i = 0;i < n;i++)
cin >> a[i];
dp[0] = a[0];
maxx = a[0];
for (int i = 1;i < n;i++)
{
dp[i] = max(dp[i - 1] + a[i], a[i]);
if (dp[i] > maxx)maxx = dp[i];
}
cout << maxx << endl;
}
}
登录后发布评论
暂无评论,来抢沙发