Advertisement
Guest User

Untitled

a guest
Aug 14th, 2017
189
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. internal class Program
  6. {
  7.     public static void Main()
  8.     {
  9.         List<long> beehives = Console.ReadLine().Split(' ').Select(long.Parse).ToList();
  10.         List<long> hornets = Console.ReadLine().Split(' ').Select(long.Parse).ToList();
  11.  
  12.         for (int i = 0; i < beehives.Count; i++)
  13.         {
  14.             if (hornets.Count == 0)
  15.             {
  16.                 break;
  17.             }
  18.             long summedHornetsPower = hornets.Sum();
  19.             if (beehives[i] >= summedHornetsPower)
  20.             {
  21.                 hornets.RemoveAt(0);
  22.                
  23.  
  24.             }
  25.             beehives[i] -= summedHornetsPower;
  26.         }
  27.         foreach (var hive in beehives)
  28.         {
  29.             if (hive > 0)
  30.             {
  31.                 Console.Write(hive + " ");
  32.             }
  33.         }
  34.         if (beehives.Exists(a => a <= 0))
  35.         {
  36.             Console.WriteLine(string.Join(" ", hornets));
  37.         }
  38.     }
  39. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement