Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace _03_Hornet_Assault
- {
- public class HornetAssault
- {
- public static void Main()
- {
- var beehives = Console.ReadLine().Split().Select(long.Parse).ToList();
- var hornets = Console.ReadLine().Split().Select(long.Parse).ToList();
- var aliveBeehives = new List<long>();
- foreach (var beehive in beehives)
- {
- if (hornets.Count == 0)
- {
- aliveBeehives.Add(beehive);
- continue;
- }
- var hornetsPower = hornets.Sum();
- if (beehive >= hornetsPower)
- {
- aliveBeehives.Add(beehive - hornetsPower);
- hornets.RemoveAt(0);
- }
- }
- aliveBeehives = aliveBeehives.Where(bh => bh > 0).ToList();
- if (aliveBeehives.Count > 0)
- {
- Console.WriteLine(string.Join(" ", aliveBeehives));
- }
- else
- {
- Console.WriteLine(string.Join(" ", hornets));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement