Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text.RegularExpressions;
- namespace L9._PokemonDon_tGo
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- List<int> pokemonList = Console.ReadLine()
- .Split(' ',StringSplitOptions.RemoveEmptyEntries)
- .Select(int.Parse)
- .ToList();
- List<int> sumList = new List<int>();
- while (pokemonList.Count > 0)
- {
- int input = int.Parse(Console.ReadLine());
- if (input < 0)
- {
- int removeOne = pokemonList[0];
- sumList.Add(pokemonList[pokemonList[0]]);
- pokemonList[0] = pokemonList[pokemonList.Count - 1];
- LoopForIncreaseAndDecrease(pokemonList, removeOne);
- }
- else if (input >= pokemonList.Count)
- {
- int removeTwo = pokemonList[pokemonList.Count - 1];
- sumList.Add(pokemonList[pokemonList.Count - 1]);
- pokemonList[pokemonList.Count - 1] = pokemonList[0];
- LoopForIncreaseAndDecrease(pokemonList,removeTwo);
- }
- else
- {
- int removeThree = pokemonList[input];
- sumList.Add(pokemonList[input]);
- pokemonList.RemoveAt(input);
- LoopForIncreaseAndDecrease(pokemonList,removeThree);
- }
- }
- Console.WriteLine(sumList.Sum());
- }
- static void LoopForIncreaseAndDecrease (List<int> pokemonList , int remove)
- {
- for (int i = 0; i < pokemonList.Count; i++)
- {
- if (pokemonList[i] <= remove)
- {
- pokemonList[i] += remove;
- }
- else
- {
- pokemonList[i] -= remove;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement