Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace _03.PokemonDon_tGo
- {
- public class StartUp
- {
- public static void Main()
- {
- var input = Console.ReadLine()
- .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
- .Select(int.Parse)
- .ToList();
- int sumOfRemovedElements = 0;
- while (input.Count > 0)
- {
- int valueOfRemovedElement = 0;
- int index = int.Parse(Console.ReadLine());
- if (index < 0)
- {
- valueOfRemovedElement = input[0];
- sumOfRemovedElements += valueOfRemovedElement;
- input[0] = input[input.Count - 1];
- ChangeValueOfElements(input, valueOfRemovedElement);
- }
- else if (index > input.Count - 1)
- {
- valueOfRemovedElement = input[input.Count - 1];
- sumOfRemovedElements += valueOfRemovedElement;
- input[input.Count - 1] = input[0];
- ChangeValueOfElements(input, valueOfRemovedElement);
- }
- else
- {
- valueOfRemovedElement = input[index];
- sumOfRemovedElements += valueOfRemovedElement;
- input.RemoveAt(index);
- ChangeValueOfElements(input, valueOfRemovedElement);
- }
- }
- Console.WriteLine(sumOfRemovedElements);
- }
- private static void ChangeValueOfElements(List<int> input, int valueOfRemovedElement)
- {
- for (int i = 0; i < input.Count; i++)
- {
- if (input[i] <= valueOfRemovedElement)
- {
- input[i] += valueOfRemovedElement;
- }
- else
- {
- input[i] -= valueOfRemovedElement;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment