Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- long long int a,i,b,c,z,f;
- long long int s,l,t=0;
- //ilosc liczb
- cin>> i;
- if (i>=1 && i<=100000)
- {
- int tab[100000];
- for (int n=0;n<i;n++)
- {
- cin>>a;
- if(a<-100000 || a>100000)
- {
- return 0;
- }
- tab[n]=a;
- l=l+1;
- if(a<0)
- {
- s=0;
- for(b=0;b<l;b++)
- {
- s=s+tab[b];
- }
- //cout<<s<<endl;
- if(s<0)
- {
- for(c=0;c<l;c++)
- {
- tab[c]=0;
- }
- }
- }continue;
- }
- z=i;
- for(int e=i;e>0;e--)
- {
- s=0;
- f=tab[e-1];
- z--;
- if(f<0)
- {
- for(b=z;b<i;b++)
- {
- s=s+tab[b];
- }
- //cout<<s<<endl;
- if(s<0)
- {
- for(c=z;c<i;c++)
- {
- tab[c]=0;
- }
- }
- }continue;
- }
- for(int d=0;d<i;d++)
- {
- t=t+tab[d];
- }
- cout<<t<<endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement