Advertisement
Guest User

02. Seize the Fire

a guest
Jun 26th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.77 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Numerics;
  4. using System.Collections.Generic;
  5.  
  6. namespace MidExam2
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             List<string> input = Console.ReadLine()
  13.                 .Split("#")
  14.                 .ToList();
  15.             int totalWater = int.Parse(Console.ReadLine());
  16.             List<int> totalTrueCells = new List<int>();
  17.             bool isThereNoLeftWater = false;
  18.             for (int i = 0; i < input.Count; i++)
  19.             {
  20.                 List<string> splitedInput = input[i].Split(" ").ToList();
  21.                 string level = splitedInput[0];
  22.                 int cels = int.Parse(splitedInput[2]);
  23.                 switch (level)
  24.                 {
  25.                     case "High":
  26.                         if (cels>= 81 && cels <= 125)
  27.                         {
  28.                             totalWater -= cels;
  29.                             if (totalWater < 0)
  30.                             {
  31.                                 isThereNoLeftWater = true;
  32.                                 break;
  33.                             }
  34.                             totalTrueCells.Add(cels);
  35.                         }
  36.                         break;
  37.                     case "Medium":
  38.                         if (cels >= 51 && cels <= 80)
  39.                         {
  40.                             totalWater -= cels;
  41.                             if (totalWater < 0)
  42.                             {
  43.                                 isThereNoLeftWater = true;
  44.                                 break;
  45.                             }
  46.                             totalTrueCells.Add(cels);
  47.                         }
  48.                         break;
  49.                     case "Low":
  50.                         if (cels >= 1 && cels <= 50)
  51.                         {
  52.                             totalWater -= cels;
  53.                             if (totalWater < 0)
  54.                             {
  55.                                 isThereNoLeftWater = true;
  56.                                 break;
  57.                             }
  58.                             totalTrueCells.Add(cels);
  59.                         }
  60.                         break;
  61.                 }
  62.                 if (isThereNoLeftWater)
  63.                 {
  64.                     break;
  65.                 }
  66.             }
  67.                 double totalFire = 0;
  68.                 Console.WriteLine("Cells:");
  69.                 for (int i = 0; i < totalTrueCells.Count; i++)
  70.                 {
  71.                     totalFire += totalTrueCells[i];
  72.                     Console.WriteLine($" - {totalTrueCells[i]}");
  73.                 }
  74.                 Console.WriteLine($"Effort: {totalFire / 4:f2}");
  75.                 Console.WriteLine($"Total Fire: {totalFire}");
  76.         }
  77.     }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement