Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.53 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. long water = long.Parse(Console.ReadLine());
  19. double totalEffort = 0;
  20. long totalFire = 0;
  21. bool isItLegit = false;
  22. long counter = 0;
  23.  
  24. for (long i = 0; i < input.Length; i++)
  25. {
  26. string[] current = input[i].Split(new[] { "=", " " }, StringSplitOptions.RemoveEmptyEntries).ToArray();
  27. string typeOfFire = current[0];
  28. long valueOfFire = long.Parse(current[1]);
  29.  
  30. isItLegit = false;
  31.  
  32. switch (typeOfFire)
  33. {
  34. case "High":
  35. if (valueOfFire >= 81 && valueOfFire < 126 && water >= valueOfFire) //check if it's exclussive or not.
  36. {
  37. isItLegit = true;
  38. }
  39. break;
  40.  
  41. case "Medium":
  42. if (valueOfFire >= 51 && valueOfFire < 81 && water >= valueOfFire) //check if it's exclussive or not.
  43. {
  44. isItLegit = true;
  45. }
  46. break;
  47.  
  48. case "Low":
  49. if (valueOfFire >= 1 && valueOfFire < 51 && water >= valueOfFire) //check if it's exclussive or not.
  50. {
  51. isItLegit = true;
  52. }
  53. break;
  54.  
  55. default:
  56. break;
  57. }
  58.  
  59. if (isItLegit)
  60. {
  61. counter++;
  62. water -= valueOfFire;
  63. totalEffort += Math.Round(0.25 * valueOfFire, 2);
  64. totalFire += valueOfFire;
  65.  
  66. if (counter == 1)
  67. {
  68. Console.WriteLine("Cells:");
  69. }
  70.  
  71. Console.WriteLine($" - {valueOfFire}");
  72. }
  73. }
  74.  
  75. Console.WriteLine($"Effort: {totalEffort:f2}");
  76. Console.WriteLine($"Total Fire: {totalFire}");
  77. }
  78. }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement