Advertisement
rengetsu

Codeforces_427A

Jul 15th, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. // Codeforces 427A
  2.  
  3. #include <iostream>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     int n, q, pol = 0, rez = 0;
  10.     cin >> n;
  11.     for( int i = 0; i < n; i++ )
  12.     {
  13.         cin >> q;
  14.         if( q == -1 )
  15.         {
  16.             if( pol > 0 )
  17.             {
  18.                 pol--;
  19.             }
  20.             else
  21.             {
  22.                 rez++;
  23.             }
  24.         }
  25.         else
  26.         {
  27.             pol += q;
  28.         }
  29.     }
  30.     cout << rez;
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement