#2WA了
查看原帖
#2WA了
295504
Into_qwq楼主2020/5/5 22:22
#include<iostream>
#include<cstdio>
typedef long long ll;
using namespace std;
const int N=200000;
ll arr[N+5],dp[N+5],ans;//now&&sum
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++) cin>>arr[i];
    for(int i=1;i<=n;i++)
    {
        if(dp[i-1]+arr[i]<0) dp[i]=0;
        else dp[i]=dp[i-1]+arr[i];
        ans=max(ans,dp[i]);
    }
    cout<<ans;
    return 0;
}
2020/5/5 22:22
加载中...