Guest User

Untitled

a guest
Feb 5th, 2018
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.12 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Runtime.CompilerServices;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8.  
  9.  
  10.  
  11. class Program
  12. {
  13. private const int maxBedsDepartment = 60;
  14.  
  15. static void Main()
  16. {
  17. var departmentPatients = new Dictionary<string, HashSet<string>>();
  18. var doctorsPatients = new Dictionary<string, HashSet<string>>();
  19.  
  20. while (true)
  21. {
  22. string input = Console.ReadLine();
  23. if (input == "Output")
  24. break;
  25.  
  26. string[] data = input
  27. .Split(" \t\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)
  28. .ToArray();
  29. string departmentName = data[0].Trim();
  30. string doctorName = data[1].Trim() + " " + data[2].Trim();
  31. string patientsName = data[3];
  32.  
  33. if (!departmentPatients.ContainsKey(departmentName))
  34. {
  35. departmentPatients[departmentName] = new HashSet<string>();
  36. }
  37.  
  38. if (!doctorsPatients.ContainsKey(doctorName))
  39. {
  40. doctorsPatients[doctorName] = new HashSet<string>();
  41. }
  42.  
  43. if (departmentPatients[departmentName].Count >= maxBedsDepartment)
  44. {
  45. continue;
  46. }
  47.  
  48. departmentPatients[departmentName].Add(patientsName);
  49. doctorsPatients[doctorName].Add(patientsName);
  50. }
  51.  
  52. while (true)
  53. {
  54. string[] input = Console.ReadLine()
  55. .Split(" \t\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)
  56. .ToArray();
  57. if (input[0] == "End")
  58. break;
  59. int coutOfSearchElements = input.Length;
  60. switch (coutOfSearchElements)
  61. {
  62. case 1:
  63. string seachedDepartment = input[0];
  64. if (departmentPatients.ContainsKey(seachedDepartment))
  65. {
  66. departmentPatients[seachedDepartment].ToList()
  67. .ForEach(p=>Console.WriteLine(p));
  68. }
  69. break;
  70. case 2:
  71. string searchedDoctor = input[0] + " " + input[1];
  72. if (doctorsPatients.ContainsKey(searchedDoctor))
  73. {
  74. doctorsPatients[searchedDoctor].OrderBy(x => x)
  75. .ToList()
  76. .ForEach(p=>Console.WriteLine(p));
  77. }
  78. else
  79. {
  80. string currentDepartmen = input[0];
  81. int searchedRoom = int.Parse(input[1]);
  82. departmentPatients[currentDepartmen]
  83. .Skip((searchedRoom*3)-3)
  84. .Take(3)
  85. .OrderBy(x=>x)
  86. .ToList()
  87. .ForEach(p=>Console.WriteLine(p));
  88. }
  89. break;
  90. }
  91. }
  92. }
  93. }
Advertisement
Add Comment
Please, Sign In to add comment