Advertisement
GabrielDas

Untitled

Mar 11th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.96 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace P01
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. List<string> fireCells = Console.ReadLine().Split('#').ToList();
  12. double amountOfWater = Double.Parse(Console.ReadLine());
  13. List<string> availableCells = new List<string>();
  14.  
  15.  
  16.  
  17. double effort = 0;
  18. double totalFire = 0;
  19.  
  20.  
  21. for (int i = 0; i < fireCells.Count; i++)
  22. {
  23. string[] tokens = fireCells[i].Split(" = ").ToArray();
  24. string typeOfFire = tokens[0];
  25. int valueOfCell = int.Parse(tokens[1]);
  26. string output = " - " + tokens[1];
  27.  
  28. if (typeOfFire == "High" && (valueOfCell >= 81 && valueOfCell <= 125))
  29. {
  30. if (amountOfWater >= valueOfCell)
  31. {
  32. amountOfWater -= valueOfCell;
  33. effort += (0.25) * valueOfCell;
  34. totalFire += valueOfCell;
  35. availableCells.Add(output);
  36.  
  37.  
  38. }
  39. else
  40. {
  41. continue;
  42. }
  43. // availableCells.Add();
  44.  
  45. }
  46. else if (typeOfFire == "Medium" && (valueOfCell >= 51 && valueOfCell <= 80))
  47. {
  48. if (amountOfWater >= valueOfCell)
  49. {
  50. amountOfWater -= valueOfCell;
  51. effort += (0.25) * valueOfCell;
  52. totalFire += valueOfCell;
  53. availableCells.Add(output);
  54. }
  55. else
  56. {
  57. continue;
  58. }
  59. }
  60. else if (typeOfFire == "Low" && (valueOfCell >= 1 && valueOfCell <= 50))
  61. {
  62.  
  63. if (amountOfWater >= valueOfCell)
  64. {
  65. amountOfWater -= valueOfCell;
  66. effort += (0.25) * valueOfCell;
  67. totalFire += valueOfCell;
  68. availableCells.Add(output);
  69. }
  70. else
  71. {
  72. continue;
  73. }
  74. }
  75.  
  76. }
  77.  
  78. Console.WriteLine("Cells:");
  79. foreach (var item in availableCells)
  80. {
  81. Console.WriteLine(item);
  82. }
  83.  
  84.  
  85. Console.WriteLine($"Effort: {effort:0.00}");
  86. Console.WriteLine($"Total Fire: {totalFire}");
  87.  
  88. }
  89. }
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement