Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace HomeWork
- {
- class Program
- {
- static void Main(string[] args)
- {
- var input = Console.ReadLine();
- var numbers = Console.ReadLine().Split(' ').Select(int.Parse);
- var tokens = input.Split(' ').Select(int.Parse).ToArray();
- var numbersCollection = new Stack<int>(numbers);
- var count = tokens[1];
- var min = 10000000000000;
- for (int i = 0; i < count; i++)
- {
- numbersCollection.Pop();
- }
- if (numbersCollection.Contains(tokens[2]))
- {
- Console.WriteLine("true");
- }
- else
- {
- if (numbersCollection.Count > 0)
- {
- foreach (var item in numbersCollection)
- {
- if (min > item)
- {
- min = item;
- }
- }
- Console.WriteLine(min);
- }
- else
- {
- Console.WriteLine("0");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement