Advertisement
Guest User

Untitled

a guest
Jun 14th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.35 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4.  
  5. namespace Legendary
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11.  
  12. SortedDictionary<string, int> neededItems = new SortedDictionary<string, int>() { {"shards" , 0} , {"fragments" , 0}, {"motes" , 0} };
  13. SortedDictionary<string, int> trashItems = new SortedDictionary<string, int>();
  14.  
  15. List<int> quantity = new List<int>();
  16. List<string> namesOfMaterials = new List<string>();
  17.  
  18. string legendaryItem = String.Empty;
  19. bool end = true;
  20.  
  21. while (end)
  22. {
  23. var input = Console.ReadLine().Split(" ").ToArray();
  24. int quantityOfMaterial = 0;
  25.  
  26.  
  27.  
  28. for (int i = 0; i < input.Length; i+=2)
  29. {
  30. quantityOfMaterial = int.Parse(input[i]);
  31. quantity.Add(quantityOfMaterial);
  32.  
  33.  
  34. }
  35.  
  36. for (int i = 1; i < input.Length; i+=2)
  37. {
  38. var name = input[i].ToLower();
  39. namesOfMaterials.Add(name);
  40. }
  41.  
  42. for (int i = 0; i < namesOfMaterials.Count; i++)
  43. {
  44. if (neededItems.ContainsKey(namesOfMaterials[i]))
  45. {
  46. neededItems[namesOfMaterials[i]] += quantity[i];
  47.  
  48. if (neededItems[namesOfMaterials[i]] >= 250)
  49. {
  50. neededItems[namesOfMaterials[i]] -= 250;
  51. legendaryItem = namesOfMaterials[i];
  52.  
  53. if (legendaryItem == "fragments")
  54. {
  55. legendaryItem = "Valanyr obtained!";
  56.  
  57. }
  58. else if (legendaryItem == "shards")
  59. {
  60. legendaryItem = "Shadowmourne obtained!";
  61. }
  62. else
  63. {
  64. legendaryItem = "Dragonwrath obtained!";
  65. }
  66. end = false;
  67. break;
  68. }
  69.  
  70. }
  71. else if (trashItems.ContainsKey(namesOfMaterials[i]) == false)
  72. {
  73. trashItems.Add(namesOfMaterials[i], quantity[i]);
  74.  
  75. }
  76. else if (trashItems.ContainsKey(namesOfMaterials[i]))
  77. {
  78. trashItems[namesOfMaterials[i]] += quantity[i];
  79. }
  80.  
  81. }
  82.  
  83.  
  84. namesOfMaterials.Clear();
  85. quantity.Clear();
  86.  
  87.  
  88. }
  89.  
  90. Console.WriteLine(legendaryItem);
  91.  
  92. foreach (var item in neededItems.OrderByDescending(c => c.Value))
  93. {
  94. Console.WriteLine($"{item.Key}: {item.Value}");
  95. }
  96.  
  97. foreach (var item in trashItems)
  98. {
  99. Console.WriteLine($"{item.Key}: {item.Value}");
  100. }
  101.  
  102. }
  103.  
  104.  
  105. }
  106.  
  107.  
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement