Advertisement
MyOnAsSalat

Untitled

Apr 27th, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.89 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Competition
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Console.ReadLine();
  14.             var a = Console.ReadLine().Split(' ').Select(x => Convert.ToInt32(x)).ToArray();
  15.             int kop = 0;
  16.             int result = 0;
  17.             foreach (var i in a)
  18.             {
  19.                 if (i == -1)
  20.                 {
  21.                     if (kop == 0)
  22.                     {
  23.                         result++;
  24.                     }
  25.                     else
  26.                     {
  27.                         kop--;
  28.                     }
  29.                 }
  30.                 else
  31.                 {
  32.                     kop += i;
  33.                 }
  34.             }
  35.             Console.WriteLine(result);
  36.         }
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement