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