Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- namespace _03MaximumElement
- {
- class MaximumElement
- {
- static void Main(string[] args)
- {
- int queryCount = int.Parse(Console.ReadLine());
- Stack<int> stackNums = new Stack<int>();
- for (int i = 0; i < queryCount; i++)
- {
- int[] query = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
- switch (query[0])
- {
- case 1:
- stackNums.Push(query[1]);
- break;
- case 2:
- stackNums.Pop();
- break;
- case 3:
- Console.WriteLine(stackNums.Max());
- break;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement