Advertisement
Guest User

Untitled

a guest
Aug 14th, 2017
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 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 _3.HornetAssault
  8. {
  9. class HornetAssault
  10. {
  11. static void Main()
  12. {
  13. List<long> beehives = Console.ReadLine().Split().Select(long.Parse).ToList();
  14. List<long> hornet = Console.ReadLine().Split().Select(long.Parse).ToList();
  15. long Power = hornet.Sum();
  16. for (int i = 0; i < beehives.Count; i++)
  17. {
  18. if (hornet.Count == 0)
  19. {
  20. break;
  21. }
  22. if (Power > beehives[i])
  23. {
  24. beehives[i] = 0;
  25. }
  26. else
  27. {
  28. beehives[i] -= Power;
  29. hornet.RemoveAt(0);
  30. Power = hornet.Sum();
  31. }
  32.  
  33. }
  34.  
  35. if (beehives.All(x => x == 0))
  36. {
  37. Console.WriteLine(string.Join(" ", hornet));
  38. }
  39. else
  40. {
  41. Console.WriteLine(string.Join(" ", beehives.Where(x => x != 0).ToList()));
  42. }
  43. }
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement