-
-
Save fredbr/4e87f503be2fda44cf316babf4c4e9ae to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// codigo de Larissa Mesquita | |
#include <iostream> | |
using namespace std; | |
#define MAX 50010 | |
int v[MAX], n; | |
int f(){ | |
int atual=0, maior=0; | |
for(int i=0;i<n;i++){ | |
atual=max(0, atual+v[i]); | |
maior=max(maior, atual); | |
} | |
return maior; | |
} | |
int main(){ | |
cin>>n; | |
for(int i=0;i<n;i++) | |
cin>>v[i]; | |
cout<<f()<<endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment