Advertisement
IvaAnd

Untitled

Oct 19th, 2020
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. public class Bombs {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. int[] line = Arrays.stream(scanner.nextLine().split(", "))
  8. .mapToInt(Integer::parseInt).toArray();
  9.  
  10. ArrayDeque<Integer> queEffect = new ArrayDeque();
  11.  
  12. for (int i = 0; i < line.length; i++) {
  13. queEffect.offer(line[i]);
  14. }
  15.  
  16. line = Arrays.stream(scanner.nextLine().split(", "))
  17. .mapToInt(Integer::parseInt).toArray();
  18. ArrayDeque<Integer> staCasings = new ArrayDeque();
  19. for (int i = 0; i < line.length; i++) {
  20. staCasings.push(line[i]);
  21. }
  22.  
  23. Map<String, Integer> bombs = new LinkedHashMap<>();
  24. bombs.put("Datura Bombs", 0);
  25. bombs.put("Cherry Bombs", 0);
  26. bombs.put("Smoke Decoy Bombs", 0);
  27.  
  28. while (queEffect.size() > 0 && staCasings.size() > 0) {
  29. int effect = queEffect.peek();
  30. int casing = staCasings.peek();
  31. int result = effect + casing;
  32.  
  33. while (result != 40 && result != 60 && result != 120) {
  34. result -= 5;
  35. }
  36. switch (result) {
  37. case 40:
  38. queEffect.poll();
  39. staCasings.pop();
  40. String currentBomb = "Datura Bomb";
  41. bombs.put(currentBomb, bombs.get(currentBomb) + 1);
  42. // box.put(currBomb, box.get(currBomb) + 1);
  43.  
  44. break;
  45. case 60:
  46. queEffect.poll();
  47. staCasings.pop();
  48. // int daturaCount = bombs.get("Datura Bomb");
  49. bombs.put("Cherry Bomb", bombs.get("Cherry Bomb") + 1);
  50. break;
  51. case 120:
  52. bombs.put("Smoke Decoy Bombs", bombs.get("Smoke Decoy Bombs") + 1);
  53. break;
  54. }
  55.  
  56.  
  57. }
  58. }
  59.  
  60. }
  61.  
  62.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement