Advertisement
Guest User

Untitled

a guest
Jan 24th, 2018
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.88 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4.  
  5. namespace _03MaximumElement
  6. {
  7.     class MaximumElement
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             int queryCount = int.Parse(Console.ReadLine());
  12.             Stack<int> stackNums = new Stack<int>();
  13.             for (int i = 0; i < queryCount; i++)
  14.             {
  15.                 int[] query = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
  16.                 switch (query[0])
  17.                 {
  18.                     case 1:
  19.                         stackNums.Push(query[1]);
  20.                         break;
  21.                     case 2:
  22.                         stackNums.Pop();
  23.                         break;
  24.                     case 3:
  25.                         Console.WriteLine(stackNums.Max());
  26.                         break;
  27.                 }
  28.             }
  29.         }
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement