static void Main(String[] args) { string[] tokens = Console.ReadLine().Split(); int N = int.Parse(tokens[0]); int S = int.Parse(tokens[1]); int pfCount = 0; // page fault count LRU lruObj = new LRU(); for (int T = N; T > 0;) { tokens = Console.ReadLine().Split(); T -= tokens.Length; for (int i = 0; i < tokens.Length; i++) { int item = int.Parse(tokens[i]); ListNode pos = lruObj.find(item); if (pos == null) { if (lruObj.Count == S) { lruObj.Dequeue(); } lruObj.Enqueue(item); pfCount++; } else { lruObj.UpdateAsMRU(pos); } } } Console.WriteLine(pfCount); Console.WriteLine(lruObj.GetAllItems()); }