Advertisement
SergeyPGUTI

10.1.5 Гиперпереход

Apr 4th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.34 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5.  
  6. int main()
  7. {
  8.  
  9.     int N,sum=0,Max=0;
  10.     cin>>N;
  11.     int *a=new int[N];
  12.     for (int i=0;i<N;i++)
  13.     {
  14.         cin>>a[i];
  15.     }
  16.      for (int i=0;i<N;i++)
  17.     {
  18.         sum+=a[i];
  19.         if (sum<0) sum=0;
  20.         if (sum>Max) Max=sum;
  21.     }
  22.     cout<<Max;
  23.     return 0;
  24.  
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement