Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- internal class Program
- {
- public static void Main()
- {
- List<long> beehives = Console.ReadLine().Split(' ').Select(long.Parse).ToList();
- List<long> hornets = Console.ReadLine().Split(' ').Select(long.Parse).ToList();
- for (int i = 0; i < beehives.Count; i++)
- {
- if (hornets.Count == 0)
- {
- break;
- }
- long summedHornetsPower = hornets.Sum();
- if (beehives[i] >= summedHornetsPower)
- {
- hornets.RemoveAt(0);
- }
- beehives[i] -= summedHornetsPower;
- }
- var hasPrint = false;
- foreach (var hive in beehives.Where( x => x > 0))
- {
- Console.Write(hive + " ");
- hasPrint = true;
- }
- if(!hasPrint)
- {
- Console.WriteLine(string.Join(" ", hornets));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement