Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<cstdio>
- #include<cstring>
- using namespace std;
- int main()
- {
- int dia;
- int soma;
- int maximo;
- int n;
- while(scanf("%d",&n)!=EOF)
- {
- if(n==0)
- {
- break;
- }
- maximo=-101;
- soma=0;
- for(int i=0; i<n; i++)
- {
- scanf("%d",&dia);
- soma+=dia;
- if(soma>maximo)
- {
- maximo=soma;
- }
- if(soma<0)
- {
- soma=0;
- }
- }
- printf("%d\n", maximo);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement