Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- using System.Text;
- public class Program
- {
- public static void Main()
- {
- int maxBeds = 60;
- Dictionary<string,List<string>> deptPatients = new Dictionary<string,List<string>>();
- Dictionary<string,List<string>> doctorPatients = new Dictionary<string,List<string>>();
- while(true)
- {
- string command = Console.ReadLine();
- if(command == "Output")
- {
- break;
- }
- string[] tokens = command.Split(new char[]{' '},StringSplitOptions.RemoveEmptyEntries);
- string dept = tokens[0];
- string docNames = tokens[1] + " " + tokens[2];
- string patient = tokens[3];
- if(!deptPatients.ContainsKey(dept))
- {
- deptPatients.Add(dept, new List<string>());
- }
- if(!doctorPatients.ContainsKey(docNames))
- {
- doctorPatients.Add(docNames, new List<string>());
- }
- if(deptPatients[dept].Count>=maxBeds)
- {
- continue;
- }
- deptPatients[dept].Add(patient);
- doctorPatients[docNames].Add(patient);
- }
- while(true)
- {
- string input = Console.ReadLine();
- if(input == "End")
- {
- break;
- }
- string[] tokens = input.Split(new char[]{' '},StringSplitOptions.RemoveEmptyEntries);
- if(tokens.Length==1)
- {
- string dept = tokens[0];
- foreach(var kvp in deptPatients)
- {
- string deptName = kvp.Key;
- List<string> patients = kvp.Value;
- if(deptName==dept)
- {
- foreach(var patient in patients)
- {
- Console.WriteLine(patient);
- }
- }
- }
- }
- else
- {
- string secondWord = tokens[1];
- if(char.IsDigit(secondWord[0]))
- {
- string dept = tokens[0];
- int roomNum = int.Parse(tokens[1]);
- if(deptPatients.ContainsKey(dept))
- {
- var filtered = deptPatients[dept].Skip((roomNum*3)-3).Take(3).ToList();
- foreach(var patient in filtered.OrderBy(x=>x))
- {
- Console.WriteLine(patient);
- }
- }
- }
- else
- {
- string docNames = tokens[0] + " " + tokens[1];
- foreach(var kvp in doctorPatients)
- {
- string names = kvp.Key;
- List<string> patients = kvp.Value;
- if(names == docNames)
- {
- foreach(var patient in patients.OrderBy(x=>x))
- {
- Console.WriteLine(patient);
- }
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement