Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _03.MaximumElement
- {
- using System.Collections.Generic;
- using System.Linq;
- public class MaximumElement
- {
- public static void Main(string[] args)
- {
- int queriesCount = int.Parse(Console.ReadLine());
- var elements = new Stack<int>();
- for (int i = 0; i < queriesCount; i++)
- {
- string querie = Console.ReadLine();
- switch (querie)
- {
- case "2":
- elements.Pop();
- break;
- case "3":
- Console.WriteLine(elements.Max());
- break;
- default:
- elements.Push(int.Parse(querie.Substring(2)));
- break;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement