Advertisement
MeGaM1nd

Untitled

Apr 7th, 2020
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. import java.util.ArrayList;
  2. import java.util.Arrays;
  3. import java.util.List;
  4. import java.util.Scanner;
  5.  
  6. public class Shoot {
  7. public static void main(String[] args) {
  8.  
  9. Scanner scanner = new Scanner(System.in);
  10.  
  11. String[] split = scanner.nextLine().split("\\+s"){
  12. List<Integer> target = new ArrayList<>();
  13. List<String> results = new ArrayList<>();
  14.  
  15. for (String s: split) {
  16. String command = scanner.nextLine();
  17.  
  18. while (!command.equals("End")){
  19.  
  20. int indexShoots = Integer.parseInt(command){
  21. if (indexShoots >= 0 && indexShoots < target.size()){
  22.  
  23. int valueOfTheTarget = target.get(indexShoots);
  24.  
  25. for (int i = 0; i <target.size() ; i++) {
  26. int currents = target.get(1);
  27.  
  28.  
  29. if (i == indexShoots){
  30. continue;
  31. } else if (currents == -1){
  32. continue;
  33. }
  34. if (currents <= valueOfTheTarget){
  35. currents += valueOfTheTarget;
  36.  
  37.  
  38. target.set(i, currents);
  39. } else {
  40. currents -= valueOfTheTarget;
  41. }
  42. }
  43. }
  44. }
  45. }
  46. }
  47. }
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement