Advertisement
Guest User

Untitled

a guest
Feb 7th, 2025
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.82 KB | None | 0 0
  1. namespace _05
  2. {
  3.     internal class Program
  4.     {
  5.         static void Main(string[] args)
  6.         {
  7.             List<int> list = Console.ReadLine().Split().Select(int.Parse).ToList();
  8.             List<int> bomb = Console.ReadLine().Split().Select(int.Parse).ToList();
  9.  
  10.             for (int i = 0; i < list.Count; i++)
  11.             {
  12.                 if (list[i] == bomb[0])
  13.                 {
  14.                 int bombSpreadStart = Math.Max((i - bomb[1]), 0);
  15.                 int bombSpreadEnd = Math.Min((i + bomb[1]), (list.Count-1));
  16.  
  17.                     for (int j = bombSpreadEnd; j >= bombSpreadStart; j--)
  18.                     {
  19.                         list.RemoveAt(bombSpreadStart);
  20.                     }
  21.                 i = 0;
  22.                 }
  23.             }
  24.             Console.WriteLine(list.Sum());
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement