You are viewing a single comment's thread. Return to all comments →
c# using sortedlist
static void Main(string[] args) { const bool DUMMY = false; int Q = int.Parse(Console.ReadLine()); var ints = new SortedList<int, bool>(); int minInt = int.MaxValue; for (int i = 0; i < Q; i++) { string[] arr = Console.ReadLine().Split(' '); if (arr[0] == "1") { var a = int.Parse(arr[1]); if (a < minInt) { minInt = a; } if (!ints.ContainsKey(a)) { ints.Add(a, DUMMY); } } else if (arr[0] == "2") { var a = int.Parse(arr[1]); ints.Remove(a); if (ints.Count == 0) { minInt = int.MaxValue; } else if (a == minInt) { minInt = ints.Keys[0]; } } else if (arr[0] == "3") { Console.WriteLine(minInt); } } }
Seems like cookies are disabled on this browser, please enable them to open this website
QHEAP1
You are viewing a single comment's thread. Return to all comments →
c# using sortedlist