Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace P01
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<string> fireCells = Console.ReadLine().Split('#').ToList();
- double amountOfWater = Double.Parse(Console.ReadLine());
- List<string> availableCells = new List<string>();
- double effort = 0;
- double totalFire = 0;
- for (int i = 0; i < fireCells.Count; i++)
- {
- string[] tokens = fireCells[i].Split(" = ").ToArray();
- string typeOfFire = tokens[0];
- int valueOfCell = int.Parse(tokens[1]);
- string output = " - " + tokens[1];
- if (typeOfFire == "High" && (valueOfCell >= 81 && valueOfCell <= 125))
- {
- if (amountOfWater >= valueOfCell)
- {
- amountOfWater -= valueOfCell;
- effort += (0.25) * valueOfCell;
- totalFire += valueOfCell;
- availableCells.Add(output);
- }
- else
- {
- continue;
- }
- // availableCells.Add();
- }
- else if (typeOfFire == "Medium" && (valueOfCell >= 51 && valueOfCell <= 80))
- {
- if (amountOfWater >= valueOfCell)
- {
- amountOfWater -= valueOfCell;
- effort += (0.25) * valueOfCell;
- totalFire += valueOfCell;
- availableCells.Add(output);
- }
- else
- {
- continue;
- }
- }
- else if (typeOfFire == "Low" && (valueOfCell >= 1 && valueOfCell <= 50))
- {
- if (amountOfWater >= valueOfCell)
- {
- amountOfWater -= valueOfCell;
- effort += (0.25) * valueOfCell;
- totalFire += valueOfCell;
- availableCells.Add(output);
- }
- else
- {
- continue;
- }
- }
- }
- Console.WriteLine("Cells:");
- foreach (var item in availableCells)
- {
- Console.WriteLine(item);
- }
- Console.WriteLine($"Effort: {effort:0.00}");
- Console.WriteLine($"Total Fire: {totalFire}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement