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.Numerics;
- using System.Text;
- namespace PokemonDontGo_Exam_09July2017
- {
- class MainClass
- {
- /* */
- public static void Main()
- {
- char[] sepSpace = { ' ' };
- var input = Console.ReadLine()
- .Split(sepSpace, StringSplitOptions.RemoveEmptyEntries)
- .Select(long.Parse)
- .ToList();
- var inputCopy = new List<long>();
- for (int a = 0; a < input.Count; a++)
- {
- inputCopy.Add(input[a]);
- }
- long valueOfRemoved = 0;
- long valueExchange = 0;
- var listOfRemoved = new List<long>();
- while(inputCopy.Count > 0)
- {
- int index = int.Parse(Console.ReadLine());
- if(index >= 0 && index <= inputCopy.Count - 1)//return <=, necessary if
- {
- valueOfRemoved = input[index];
- listOfRemoved.Add(valueOfRemoved);
- inputCopy.RemoveAt(index);
- for (int i = 0; i < inputCopy.Count; i++)
- {
- if(inputCopy[i] <= valueOfRemoved)
- {
- inputCopy[i] += valueOfRemoved;
- }
- else
- {
- inputCopy[i] -= valueOfRemoved;
- }
- }
- }
- else if(index < 0)
- {
- valueOfRemoved = inputCopy[0];
- listOfRemoved.Add(valueOfRemoved);
- valueExchange = inputCopy[inputCopy.Count - 1];
- inputCopy[0] = valueExchange;
- for (int z = 0; z < inputCopy.Count; z++)
- {
- if(inputCopy[z] <= valueOfRemoved)
- {
- inputCopy[z] += valueOfRemoved;
- }
- else
- {
- inputCopy[z] -= valueOfRemoved;
- }
- }
- }
- else
- {
- valueOfRemoved = inputCopy[inputCopy.Count - 1];
- listOfRemoved.Add(valueOfRemoved);
- valueExchange = inputCopy[0];
- inputCopy[inputCopy.Count - 1] = valueExchange;
- for (int f = 0; f < inputCopy.Count; f++)
- {
- if(inputCopy[f] <= valueOfRemoved)
- {
- inputCopy[f] += valueOfRemoved;
- }
- else
- {
- inputCopy[f] -= valueOfRemoved;
- }
- }
- }
- }
- Console.Write(listOfRemoved.Sum());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement