Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.96 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _02.Pokemon_Don_t_Go
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             var inputLine = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
  14.             var removedElements = new List<int>();
  15.             int removed = 0;
  16.             while (inputLine.Count != 0)
  17.             {
  18.                 int index = int.Parse(Console.ReadLine());
  19.  
  20.                 if (index < 0)
  21.                 {
  22.                     index = 0;
  23.                     removed = inputLine[index];
  24.                     removedElements.Add(removed);
  25.                     inputLine.RemoveAt(index);
  26.                     inputLine.Insert(index, inputLine.Last());
  27.  
  28.                 }
  29.                 else if ( index >= 0 && index > inputLine.Count -1)  ////////// indexa da e >= 0 i > posledniq INDEX
  30.                 {
  31.                     index = inputLine.Count - 1;
  32.                     removed = inputLine[index];
  33.                     removedElements.Add(removed);
  34.                     inputLine.RemoveAt(inputLine.Count - 1);
  35.                     inputLine.Add(inputLine[0]);   /////// gurme6e i pri dobavqneto
  36.                    
  37.                 }
  38.                 else
  39.                 {
  40.                     removed = inputLine[index];
  41.                     removedElements.Add(removed);
  42.                     inputLine.RemoveAt(index);
  43.                 }
  44.  
  45.                 for (int i = 0; i < inputLine.Count; i++)
  46.                 {
  47.                     if (inputLine[i] <= removed)
  48.                     {
  49.                         inputLine[i] += removed;
  50.                     }
  51.                     else if (inputLine[i] > removed)
  52.                     {
  53.                         inputLine[i] -= removed;
  54.                     }
  55.                 }
  56.             }
  57.  
  58.             Console.WriteLine(removedElements.Sum());
  59.         }
  60.     }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement