Advertisement
Guest User

Untitled

a guest
Sep 19th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.35 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 HomeWork
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             var input = Console.ReadLine();
  14.             var numbers = Console.ReadLine().Split(' ').Select(int.Parse);
  15.            
  16.             var tokens = input.Split(' ').Select(int.Parse).ToArray();
  17.             var numbersCollection = new Stack<int>(numbers);
  18.             var count = tokens[1];
  19.             var min = 10000000000000;
  20.             for (int i = 0; i < count; i++)
  21.             {
  22.                 numbersCollection.Pop();
  23.             }
  24.             if (numbersCollection.Contains(tokens[2]))
  25.             {
  26.                 Console.WriteLine("true");
  27.             }
  28.             else
  29.             {
  30.                 if (numbersCollection.Count > 0)
  31.                 {
  32.                     foreach (var item in numbersCollection)
  33.                     {
  34.                         if (min > item)
  35.                         {
  36.                             min = item;
  37.                         }
  38.  
  39.                     }
  40.                     Console.WriteLine(min);
  41.                 }
  42.                 else
  43.                 {
  44.                     Console.WriteLine("0");
  45.                 }
  46.                
  47.             }
  48.  
  49.         }
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement