Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- ifstream fin("bac.in");
- int main()
- {
- int x, s = 0, smax = 0;
- int max = -1000, poz = 0;
- while(fin >> x)
- {
- s = s + x;
- if(s < 0)
- s = 0;
- if(s > smax)
- smax = s;
- if(x > max)
- max = x;
- if(x > 0)
- poz++;
- }
- if(poz == 0)
- cout << max;
- else
- cout << smax;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement