Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- import java.util.List;
- import java.util.Scanner;
- public class _02_SeizeTheFire {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String fire = scanner.nextLine();
- int water = Integer.parseInt(scanner.nextLine());
- String[] input = fire.split("#");
- int totalFire = 0;
- List<Integer> col = new ArrayList<>();
- for (int i = 0; i < input.length; i++) {
- String[] elem = input[i].split(" = ");
- String type = elem[0];
- int value = Integer.parseInt(elem[1]);
- int validValue = 0;
- switch (type) {
- case "High":
- if (value >= 81 && value <= 125) {
- validValue = value;
- }
- break;
- case "Medium":
- if (value >= 51 && value <= 80) {
- validValue = value;
- }
- break;
- case "Low":
- if (value >= 1 && value <= 50) {
- validValue = value;
- }
- break;
- }
- if (water < validValue) {
- continue;
- }
- water -= validValue;
- col.add(validValue);
- totalFire += validValue;
- }
- System.out.println("Cells:");
- for (int ints : col) {
- if (ints != 0) {
- System.out.println(" - " + ints);
- }
- }
- System.out.printf("Effort: %.2f%n", totalFire * 0.25);
- System.out.println("Total Fire: " + totalFire);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement