Advertisement
nikolayneykov

Untitled

Apr 15th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.22 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. namespace _2grupa_02SeizeTheFire
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             var cells = Console.ReadLine().Split("#").ToArray();
  11.             int water = int.Parse(Console.ReadLine());
  12.  
  13.             int totalFire = 0;
  14.             double effort = 0.00;
  15.  
  16.             Console.WriteLine("Cells:");
  17.  
  18.             foreach (var cell in cells)
  19.             {
  20.                 var cellsParts = cell.Split(" = ");
  21.                 var typeOfFire = cellsParts[0];
  22.                 var value = int.Parse(cellsParts[1]);
  23.  
  24.                 var isValid = (water >= value) &&
  25.                     ((typeOfFire == "High" && value >= 81 && value <= 125) ||
  26.                     (typeOfFire == "Medium" && value >= 51 && value <= 80) ||
  27.                     (typeOfFire == "Low" && value >= 1 && value <= 50));
  28.  
  29.                 if (!isValid) { continue; }
  30.  
  31.                 effort += 0.25 * value;
  32.                 totalFire += value;
  33.                 water -= value;
  34.  
  35.                 Console.WriteLine($" - {value}");
  36.             }
  37.  
  38.             Console.WriteLine($"Effort: {effort:f2}");
  39.             Console.WriteLine($"Total Fire: {totalFire}");
  40.         }
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement