Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace _04.HornetAssault
- {
- public class StartUp
- {
- public static void Main()
- {
- List<long> beehives = Console.ReadLine()
- .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
- .Select(long.Parse)
- .ToList();
- List<long> hornets = Console.ReadLine()
- .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
- .Select(long.Parse)
- .ToList();
- int length = beehives.Count;
- int attackCounter = 0;
- while (length > attackCounter && hornets.Count > 0)
- {
- long hornetsPower = hornets.Sum();
- if (hornetsPower <= beehives[attackCounter])
- {
- hornets.RemoveAt(0);
- beehives[attackCounter] -= hornetsPower;
- }
- else
- {
- beehives[attackCounter] = 0;
- }
- attackCounter++;
- }
- if (beehives.Exists(c => c != 0))
- {
- Console.WriteLine(string.Join(" ", beehives.Where(b => b != 0)));
- }
- else
- {
- Console.WriteLine(string.Join(" ", hornets));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment