Advertisement
angelneychev

02._Seize_the_Fire

Apr 15th, 2019
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.81 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace _02._Seize_the_Fire
  6. {
  7.     class Program
  8.     {
  9.         static void Main()
  10.         {
  11.             string[] inputLine = Console.ReadLine().Split("#");
  12.             int water = int.Parse(Console.ReadLine());
  13.             double effort = 0;
  14.             List<double> cells = new List<double>();
  15.             for (int i = 0; i < inputLine.Length; i++)
  16.             {
  17.                 string[] command = inputLine[i].Split(" = ");
  18.                 string typeOfFire = command[0];
  19.                 int valueOfCell = int.Parse(command[1]);
  20.                 if (water < valueOfCell)
  21.                 {
  22.                     break;
  23.                 }
  24.                 if (typeOfFire == "High" && (valueOfCell >=81 && valueOfCell <=125))
  25.                 {
  26.                     cells.Add(valueOfCell);
  27.                     water -= valueOfCell;
  28.                     effort += valueOfCell * 0.25;
  29.                 }
  30.                 else if (typeOfFire == "Medium" && (valueOfCell >= 51 && valueOfCell <= 80))
  31.                 {
  32.                     cells.Add(valueOfCell);
  33.                     water -= valueOfCell;
  34.                     effort += valueOfCell * 0.25;
  35.                 }
  36.                 else if (typeOfFire == "Low" && (valueOfCell >= 1 && valueOfCell <= 50))
  37.                 {
  38.                     cells.Add(valueOfCell);
  39.                     water -= valueOfCell;
  40.                     effort += valueOfCell * 0.25;
  41.                 }
  42.             }
  43.  
  44.             Console.WriteLine("Cells:");
  45.             foreach (var cell in cells)
  46.             {
  47.                 Console.WriteLine($" - {cell:f0}");
  48.             }
  49.  
  50.             Console.WriteLine($"Effort: {effort:f2}");
  51.  
  52.             Console.WriteLine($"Total Fire: {cells.Sum():0}");
  53.         }
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement