Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.ArrayList;
- import java.util.Arrays;
- import java.util.List;
- import java.util.Scanner;
- import java.util.stream.Collectors;
- public class SeizeTheFire {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- List<String> cells = Arrays.stream(sc.nextLine().split("\\#+"))
- .collect(Collectors.toList());
- List<Integer> cellsPutOut = new ArrayList<>();
- int water = Integer.parseInt(sc.nextLine());
- double totalEffort = 0.0;
- int totalFire = 0;
- while (water > 0) {
- for (int i = 0; i < cells.size(); i++) {
- String[] fireCell = cells.get(i).split(" = ");
- int fireCellValue = Integer.parseInt(fireCell[1]);
- if (fireCell[0].equals("High") && fireCellValue >= 81 && fireCellValue <= 125 && water >= fireCellValue) {
- totalEffort += fireCellValue * 0.25;
- totalFire += fireCellValue;
- cellsPutOut.add(fireCellValue);
- water -= fireCellValue;
- } else if (fireCell[0].equals("Medium") && fireCellValue >= 51 && fireCellValue <= 80 && water >= fireCellValue) {
- totalEffort += fireCellValue * 0.25;
- totalFire += fireCellValue;
- cellsPutOut.add(fireCellValue);
- water -= fireCellValue;
- } else if (fireCell[0].equals("Low") && fireCellValue >= 1 && fireCellValue <= 50 && water >= fireCellValue) {
- totalEffort += fireCellValue * 0.25;
- totalFire += fireCellValue;
- cellsPutOut.add(fireCellValue);
- water -= fireCellValue;
- }
- }
- break;
- }
- System.out.println("Cells: ");
- for(int cell : cellsPutOut) {
- System.out.println(" - " + cell);
- }
- System.out.printf("Effort: %.2f%n", totalEffort);
- System.out.println("Total Fire: " + totalFire);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement