Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace ConsoleApp9
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<int> list = Console.ReadLine().Split().Select(int.Parse).ToList();
- List<int> DeletedNumbers = new List<int>();
- while (list.Count!=0)
- {
- bool check = true;
- int index = int.Parse(Console.ReadLine());
- int NumberIndex =0;
- if (index<0)
- {
- //DeletedNumbers.Add(list[0]);
- list.RemoveAt(0);
- list.Insert(0,list[list.Count - 1]);
- }
- else if (index>list.Count-1)
- {
- //DeletedNumbers.Add(list[list.Count - 1]);
- list.RemoveAt(list.Count - 1);
- list.Add(list[0]);
- }
- if (index > list.Count-1)
- {
- NumberIndex = list[list.Count - 1];
- index =list.Count - 1;
- check = false;
- }
- else if (index<0)
- {
- NumberIndex = list[0];
- index = 0;
- check = false;
- }
- else
- {
- NumberIndex = list[index];
- }
- for (int i = 0; i < list.Count; i++)
- {
- if (list[i]<=NumberIndex)
- {
- list[i] += NumberIndex;
- }
- else if (list[i]>NumberIndex)
- {
- list[i] -= NumberIndex;
- }
- }
- DeletedNumbers.Add(NumberIndex);
- if (check==true)
- {
- list.RemoveAt(index);
- }
- }
- double sum = DeletedNumbers.Sum();
- Console.WriteLine(sum);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement