Skip to content

Instantly share code, notes, and snippets.

@fredbr
Created June 19, 2018 23:42
Show Gist options
  • Save fredbr/4e87f503be2fda44cf316babf4c4e9ae to your computer and use it in GitHub Desktop.
Save fredbr/4e87f503be2fda44cf316babf4c4e9ae to your computer and use it in GitHub Desktop.
// 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