Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.52 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Globalization;
  4. using System.Linq;
  5. using System.Numerics;
  6.  
  7.  
  8. namespace _10_March_2019_Group_2
  9. {
  10. class Program
  11. {
  12. static void Main(string[] args)
  13. {
  14. //PROBLEM 2 - Seize of fire
  15.  
  16. string[] input = Console.ReadLine().Split("#", StringSplitOptions.RemoveEmptyEntries).ToArray();
  17.  
  18. int water = int.Parse(Console.ReadLine());
  19. double totalEffort = 0;
  20. int totalFire = 0;
  21. bool isItLegit = false;
  22. int printCounter = 0;
  23. List<int> numbersForPrint = new List<int>();
  24.  
  25. for (int i = 0; i < input.Length; i++)
  26. {
  27. string[] current = input[i].Split(new[] { "=", " " }, StringSplitOptions.RemoveEmptyEntries).ToArray();
  28. string typeOfFire = current[0];
  29. int valueOfFire = int.Parse(current[1]);
  30.  
  31. isItLegit = false;
  32.  
  33. switch (typeOfFire)
  34. {
  35. case "High":
  36. if (valueOfFire >= 81 && valueOfFire < 126 && water >= valueOfFire)
  37. {
  38. isItLegit = true;
  39. }
  40. break;
  41.  
  42. case "Medium":
  43. if (valueOfFire >= 51 && valueOfFire < 81 && water >= valueOfFire)
  44. {
  45. isItLegit = true;
  46. }
  47. break;
  48.  
  49. case "Low":
  50. if (valueOfFire >= 1 && valueOfFire < 51 && water >= valueOfFire)
  51. {
  52. isItLegit = true;
  53. }
  54. break;
  55.  
  56. default:
  57. break;
  58. }
  59.  
  60. if (isItLegit)
  61. {
  62. printCounter++;
  63. water -= valueOfFire;
  64. totalEffort += Math.Round(0.25 * valueOfFire, 2);
  65. totalFire += valueOfFire;
  66. numbersForPrint.Add(valueOfFire);
  67. }
  68. }
  69.  
  70. Console.WriteLine("Cells:");
  71.  
  72. foreach (var num in numbersForPrint)
  73. {
  74. Console.WriteLine($" - {num}");
  75. }
  76.  
  77. Console.WriteLine($"Effort: {totalEffort:f2}");
  78. Console.WriteLine($"Total Fire: {totalFire}");
  79. }
  80. }
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement