Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace _03.HornetAssault
- {
- class HornetAssault
- {
- static void Main()
- {
- List<long> beehives = Console.ReadLine().Split(' ').Select(long.Parse).ToList();
- List<long> hornets = Console.ReadLine().Split(' ').Select(long.Parse).ToList();
- var newBeehives = new List<long>();
- long hornetsPower = hornets.Sum();
- for (int index = 0; index < beehives.Count; index++)
- {
- if (hornets.Count == 0)
- {
- break;
- }
- long beehive = beehives[index];
- if (beehive >= hornetsPower)
- {
- beehive -= hornetsPower;
- if (beehive > 0)
- {
- newBeehives.Add(beehive);
- }
- hornets.RemoveAt(0);
- hornetsPower = hornets.Sum();
- }
- }
- if (newBeehives.Count > 0)
- {
- Console.WriteLine(String.Join(" ", newBeehives));
- }
- else
- {
- Console.WriteLine(String.Join(" ", hornets));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment