Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace advanced
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] numbers = Console.ReadLine().Split().Select(int.Parse).ToArray();
- int numberPop = numbers[1];
- int numberPeek = numbers[2];
- int minEl = int.MaxValue;
- int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
- Stack<int> stack = new Stack<int>(input);
- //for (int i = 0; i < input.Length; i++)
- //{
- // for (int j = 0; j < numberPush; j++)
- // {
- // stack.Push(input[i]);
- // }
- //}
- for (int i = 0; i < numberPop; i++)
- {
- stack.Pop();
- }
- if (stack.Contains(numberPeek))
- {
- Console.WriteLine("true");
- }
- else if(stack.Count == 0)
- {
- Console.WriteLine("0");
- }
- else
- {
- // for (int i = 0; i < input.Length; i++)
- // {
- // if (input[i] < minEl)
- // {
- // minEl = input[i];
- // }
- // }
- foreach (var item in stack)
- {
- if (item < minEl)
- {
- minEl = item;
- }
- }
- Console.WriteLine(minEl);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement