//============================================================================
// Name : mmmmmmmm.cpp
// Author : sameh mohamed
// Copyright : don't try i'm warnning you......
// Description : Hello World
//============================================================================
//Egypt came then History
//Pharoas were coders but using different compilers{}{}{}{}{}}}}{{{{@#$%^^&&$$$###()()(***)))([][][][][]]][
#include<bits/stdc++.h>
#include <iostream>
#include<string>
#include<algorithm>
#include<set>
#include<vector>
#include<map>
#include<cmath>
using namespace std;
int main()
{
int n;
cin>>n;
vector<int>a;
for(int i=0;i<n;i++)
{
int v;
cin>>v;
a.push_back(v);
}
int s=LONG_MIN;
int m=0;
for(int i=0;i<n;i++)
{
m+=a[i];
if(m>s)
s=m;
if(m<0)
m=0;
}
cout<<s;
return 0;
}
Copy