Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- import java.util.Arrays;
- import java.util.List;
- import java.util.Scanner;
- public class Shoot {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String[] split = scanner.nextLine().split("\\+s"){
- List<Integer> target = new ArrayList<>();
- List<String> results = new ArrayList<>();
- for (String s: split) {
- String command = scanner.nextLine();
- while (!command.equals("End")){
- int indexShoots = Integer.parseInt(command){
- if (indexShoots >= 0 && indexShoots < target.size()){
- int valueOfTheTarget = target.get(indexShoots);
- for (int i = 0; i <target.size() ; i++) {
- int currents = target.get(1);
- if (i == indexShoots){
- continue;
- } else if (currents == -1){
- continue;
- }
- if (currents <= valueOfTheTarget){
- currents += valueOfTheTarget;
- target.set(i, currents);
- } else {
- currents -= valueOfTheTarget;
- }
- }
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement