Advertisement
YavorGrancharov

Camel_s_Back

Jun 27th, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.87 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace Camel_s_Back
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             List<int> town = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
  12.  
  13.             int back = int.Parse(Console.ReadLine());
  14.  
  15.             int round = 0;
  16.             while (town.Count > back)
  17.             {
  18.                 town.Remove(town[0]);
  19.                 town.Remove(town[town.Count - 1]);
  20.                 round++;
  21.             }
  22.            
  23.             if (round == 0)
  24.             {
  25.                 Console.WriteLine("already stable: " + string.Join(" ", town));
  26.             }
  27.             else
  28.             {
  29.                 Console.WriteLine($"{round} rounds");
  30.                 Console.WriteLine("remaining: " + string.Join(" ", town));
  31.             }
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement