Advertisement
Guest User

Untitled

a guest
Jun 10th, 2019
784
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.74 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(string[] args)
  10.         {
  11.             var list = Console.ReadLine()
  12.                 .Split("#")
  13.                 .ToList();
  14.             int water = int.Parse(Console.ReadLine());
  15.             double effort = 0;
  16.             int totalFire = 0;
  17.             var cells = new List<int>();
  18.  
  19.             for (int i = 0; i < list.Count; i++)
  20.             {
  21.                 string type = list[i].Split(" = ")[0];
  22.                 int cell = int.Parse(list[i].Split(" = ")[1]);
  23.                 if (type == "High" && cell >= 81 && cell <= 125 && water >= cell)
  24.                 {
  25.                     cells.Add(cell);
  26.                     effort += cell * 0.25;
  27.                     totalFire += cell;
  28.                     water -= cell;
  29.                 }
  30.                 if (type == "Medium" && cell >= 51 && cell <= 80 && water >= cell)
  31.                 {
  32.                     cells.Add(cell);
  33.                     effort += cell * 0.25;
  34.                     totalFire += cell;
  35.                     water -= cell;
  36.                 }
  37.                 if (type == "Low" && cell >= 1 && cell <= 50 && water >= cell)
  38.                 {
  39.                     cells.Add(cell);
  40.                     effort += cell * 0.25;
  41.                     totalFire += cell;
  42.                     water -= cell;
  43.                 }
  44.             }
  45.             Console.WriteLine("Cells:");
  46.             foreach (var cell in cells)
  47.             {
  48.                 Console.WriteLine($"- {cell}");
  49.             }
  50.             Console.WriteLine($"Effort: {effort:F2}");
  51.             Console.WriteLine($"Total Fire: {totalFire}");
  52.         }
  53.     }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement