Aliendreamer

hornetsassault 70/100

May 28th, 2017
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.10 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace hornetAssault
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.  
  14.             //input
  15.  
  16.             List<long> beehives = Console.ReadLine().Split(' ').Select(Int64.Parse).ToList();
  17.  
  18.             List<long> hornets = Console.ReadLine().Split(' ').Select(Int64.Parse).ToList();
  19.  
  20.             // TODO logic
  21.  
  22.             long hornetsPower = hornets.Sum();
  23.  
  24.             List<long> beesAlive = new List<long>();
  25.  
  26.             for (int i = 0; i < beehives.Count; i++)
  27.             {
  28.                 if (hornets.Count != 0)
  29.                 {
  30.                     foreach (long item in beehives)
  31.                     {
  32.  
  33.                         if (item >= hornetsPower)
  34.                         {
  35.                             long difference = item - hornetsPower;
  36.  
  37.                             if (difference != 0)
  38.                             {
  39.                                 beesAlive.Add(difference);
  40.                             }
  41.                             hornetsPower = hornetsPower - hornets[0];
  42.  
  43.                             hornets.RemoveAt(0);
  44.                         }
  45.                         else
  46.                         {
  47.                             continue;
  48.  
  49.                         }
  50.                     }
  51.                     break;
  52.                 }
  53.  
  54.  
  55.  
  56.             }
  57.  
  58.             if (beesAlive.Count != 0)
  59.             {
  60.                 string otherfinal = "";
  61.                 foreach (int num in beesAlive)
  62.                 {
  63.                     otherfinal = otherfinal += num + " ";
  64.                 }
  65.                 Console.WriteLine($"{otherfinal}");
  66.             }
  67.             else
  68.             {
  69.                 string final = "";
  70.                 foreach (var survived in hornets)
  71.                 {
  72.                     final = final += survived + " ";
  73.  
  74.                     //     box = box += value + " ";
  75.  
  76.                 }
  77.                 Console.WriteLine("{0}", final);
  78.             }
  79.  
  80.  
  81.  
  82.  
  83.         }
  84.     }
  85. }
Advertisement
Add Comment
Please, Sign In to add comment