Advertisement
CR7CR7

bomb

Oct 20th, 2022
1,363
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.67 KB | None | 0 0
  1. import java.util.Arrays;
  2. import java.util.List;
  3. import java.util.Scanner;
  4. import java.util.stream.Collectors;
  5.  
  6. public class BombNumbers {
  7.     public static void main(String[] args) {
  8.         Scanner scanner = new Scanner(System.in);
  9.         List<Integer> numbersList = Arrays.stream(scanner.nextLine().split(" "))
  10.                 .map(Integer::parseInt).collect(Collectors.toList());
  11.         String commandLine = scanner.nextLine();
  12.         int bombNumber = Integer.parseInt(commandLine.split(" ")[0]);
  13.         int power = Integer.parseInt(commandLine.split(" ")[1]);
  14.         if (numbersList.contains(bombNumber)) {
  15.             for (int i = 0; i < numbersList.size(); i++) {
  16.                 int currentElement = numbersList.get(i);
  17.                 if (currentElement == bombNumber) {
  18.                     int startIndex = i - power;
  19.                     if (startIndex < 0) {
  20.                         startIndex = 0;
  21.                     }
  22.                     int endIndex = i + power;
  23.                     if (endIndex > numbersList.size() - 1) {
  24.                         endIndex = numbersList.size() - 1;
  25.                     }
  26.                    int counter = (endIndex - startIndex) + 1;
  27.                     /*for (int j = 1; j <= counter; j++) {
  28.                         numbersList.remove(startIndex);
  29.                     }*/
  30.                     for (int j = startIndex; j <=endIndex ; j++) {
  31.                         numbersList.set(j,0);
  32.                     }
  33.  
  34.                 }
  35.             }
  36.         }
  37.         int sum = 0;
  38.         for (int i = 0; i < numbersList.size(); i++) {
  39.             sum += numbersList.get(i);
  40.         }
  41.         System.out.println(sum);
  42.     }
  43. }
Advertisement
Comments
  • onegeorge555
    2 years
    # text 3.20 KB | 0 0
    1. https://pastebin.com/R3Zg7Lix#fittgpDu
    2. Hi Nairaland readerz,Julian Assange was a great "sport" type,
    3. not many people realize that Julian Assange did brilliant things.
    4. Did you know his personal Diarys auctioned for 250,000 dollars
    5. and then there was Pams clothes..oh yeah, and a Niffty NFT for
    6. a mere few million.if you like conspiracy theory sites checkout
    7. these one below great for yup coming sports!!
    8.  
    9. https://polishmexican.blogspot.com/2006/02/blogger-mess-up.html
    10. http://polishmexican.blogspot.com/2007/08/actual-polish-mexican-content.html
    11. https://shirazsocialist.wordpress.com/2017/12/21/mccluskey-jewish-news-interview/
    12. https://psychedelicdungeon.wordpress.com/2010/09/04/wikileaks-pt-2-reaction/
    13. https://rightsfreedoms.wordpress.com/2021/12/15/rfk-jrs-heroic-resistance-to-the-cias-continuing-covid-coup-detat/
    14. https://psychedelicdungeon.wordpress.com/2010/09/02/wikifreaks-pt-1-eat-pray-leak/
    15. https://www.independentsentinel.com/potential-whistleblower-named-but-not-proven/
    16. https://therapidesnote.blogspot.com/2011/04/anonymous-commenters-on-computers.html
    17. https://www.dialoginternational.com/dialog_international/2021/08/anti-vaxxers-in-germany-querdenker-anti-semites-neo-nazis.html
    18. https://www.cringely.com/2021/09/10/bobs-9-11-post-from-20-years-ago-to-a-man-with-a-hammer/
    19. https://ganglandireland.blogspot.com/2009/11/fat-freddie-thompson-riding-shotgun-for.html
    20. https://ganglandireland.blogspot.com/2009/11/gangs-of-dublin.html
    21. https://discyonki.blogspot.com/2011/11/man-is-in-love-waterboys.html
    22. https://www.afepi-ireland.com/member/smith-albert
    23. https://kaildganglife.blogspot.com/2011/03/prison-gangs-one-mexican-mafia-v.html
    24. https://tfiglobalnews.com/2021/11/22/northern-irelands-secession-from-the-united-kingdom-is-almost-a-surety-now/
    25. https://www.independentsentinel.com/potential-whistleblower-named-but-not-proven/
    26. http://www.darkpolitricks.com/2020/02/am-i-going-down-google-plug-of.html
    27. http://www.darkpolitricks.com/2022/05/here-comes-world-war-iii.html
    28. http://www.darkpolitricks.com/2021/03/is-biden-worse-than-trump.html
    29. http://www.darkpolitricks.com/2022/03/two-things-can-be-right-at-same-time.html
    30. http://www.darkpolitricks.com/2021/12/the-internet-is-dead-can-you-prove-it.html
    31. http://www.darkpolitricks.com/2021/09/the-uk-is-becoming-more-despotic-every.html
    32. http://www.darkpolitricks.com/2022/01/how-many-conspiracies-have-to-turn-true.html
    33. http://www.darkpolitricks.com/2022/03/the-stupidity-of-russian-sanctions.html
    34. http://www.darkpolitricks.com/2022/04/who-are-we-standing-with-when-we-stand.html
    35. http://www.darkpolitricks.com/2021/05/cia-agent-admits-why-usa-cant-have.html
    36. http://www.darkpolitricks.com/2018/07/israel-is-first-terrorist-state-with.html
    37. http://www.darkpolitricks.com/2020/07/covid19-were-loving-it.html
    38. http://www.darkpolitricks.com/2020/04/help-me-create-real-altnews-search.html
    39.  
    40. Thats quite alot of sites eh!? were sure youll find interesting
    41. stuff there to read their files the lot, a real Burn Baby Burn list.
    42. infact where sure youll need this naughty daughty.
    43. Hang Tight.
    44. Lee chung.
    45. Big HI to Poe and Scarebear!! hoo helped compile Santas Naughty List
    46.  
    47. HEY KAMAL TRUCKER YOU MUST THINK WE ARE REALLY STUPID OR SOMETHING.
    48.  
    49. AGENT TALLAGHT WATCHES YOU .....
    50.  
Add Comment
Please, Sign In to add comment
Advertisement