Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.06 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 Camel_sBack
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             List<int> numbers = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
  14.  
  15.             int basis = int.Parse(Console.ReadLine());
  16.  
  17.             if (numbers.Count == basis)
  18.             {
  19.                 Console.WriteLine("already stable: " + string.Join(" ", numbers));
  20.                 return;
  21.             }
  22.  
  23.             int count = 0;
  24.  
  25.             for (int i = 0; i < numbers.Count; i++)
  26.             {
  27.                 if (numbers.Count == basis)
  28.                 {
  29.                     break;
  30.                 }
  31.                 numbers.RemoveAt(i);
  32.                 numbers.Remove(numbers[numbers.Count - 1 - i]);
  33.                 count++;
  34.                 i = -1;
  35.             }
  36.             Console.WriteLine("{0} rounds", count);
  37.             Console.WriteLine("remaining: " + string.Join(" ", numbers));
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement