Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Competition
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.ReadLine();
- var a = Console.ReadLine().Split(' ').Select(x => Convert.ToInt32(x)).ToArray();
- int kop = 0;
- int result = 0;
- foreach (var i in a)
- {
- if (i == -1)
- {
- if (kop == 0)
- {
- result++;
- }
- else
- {
- kop--;
- }
- }
- else
- {
- kop += i;
- }
- }
- Console.WriteLine(result);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement