Advertisement
Guest User

Untitled

a guest
Aug 15th, 2017
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.22 KB | None | 0 0
  1. using System;
  2.  
  3. using System.Collections.Generic;
  4.  
  5. using System.Linq;
  6.  
  7.  
  8.  
  9. internal class Program
  10.  
  11. {
  12.  
  13.     public static void Main()
  14.  
  15.     {
  16.  
  17.         List<long> beehives = Console.ReadLine().Split(' ').Select(long.Parse).ToList();
  18.  
  19.         List<long> hornets = Console.ReadLine().Split(' ').Select(long.Parse).ToList();
  20.  
  21.  
  22.  
  23.         for (int i = 0; i < beehives.Count; i++)
  24.  
  25.         {
  26.  
  27.             if (hornets.Count == 0)
  28.  
  29.             {
  30.  
  31.                 break;
  32.  
  33.             }
  34.  
  35.             long summedHornetsPower = hornets.Sum();
  36.  
  37.             if (beehives[i] >= summedHornetsPower)
  38.  
  39.             {
  40.  
  41.                 hornets.RemoveAt(0);
  42.  
  43.                
  44.  
  45.  
  46.  
  47.             }
  48.  
  49.             beehives[i] -= summedHornetsPower;
  50.  
  51.         }
  52. var hasPrint = false;
  53.         foreach (var hive in beehives.Where( x => x > 0))
  54.  
  55.         {
  56.                 Console.Write(hive + " ");
  57. hasPrint = true;
  58. }
  59.  
  60.      if(!hasPrint)
  61.  
  62.         {
  63.  
  64.             Console.WriteLine(string.Join(" ", hornets));
  65.  
  66.         }
  67.  
  68.     }
  69.  
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement