Gyoshev

LegendaryFarming

Jun 1st, 2017
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace P12_LegendaryFarming
  6. {
  7. class Program
  8. {
  9. static void Main()
  10. {
  11. Dictionary<string, long> keyMaterials = new Dictionary<string, long>();
  12. SortedDictionary<string, long> junkMaterials = new SortedDictionary<string, long>();
  13. string[] input = Console.ReadLine().Split(' ');
  14. int n = input.Count();
  15. keyMaterials.Add("shards", 0);
  16. keyMaterials.Add("fragments", 0);
  17. keyMaterials.Add("motes", 0);
  18. for (int i = 0; i < n; i++)
  19. {
  20. long quantity = long.Parse(input[i]);
  21. string material = input[i + 1].ToLower();
  22. if (material == "shards" || material == "fragments" || material == "motes")
  23. {
  24. keyMaterials[material] += quantity;
  25. if (keyMaterials[material] >= 250)
  26. {
  27. keyMaterials[material] -= 250;
  28. switch (material)
  29. {
  30. case "shards": Console.WriteLine("Shadowmourne obtained!"); break;
  31. case "fragments": Console.WriteLine("Valanyr obtained!"); break;
  32. case "motes": Console.WriteLine("Dragonwrath obtained!"); break;
  33. }
  34. break;
  35. }
  36. }
  37. else
  38. {
  39. if (!junkMaterials.ContainsKey(material))
  40. {
  41. junkMaterials.Add(material, quantity);
  42. }
  43. else
  44. {
  45. junkMaterials[material] += quantity;
  46. }
  47. }
  48. i++;
  49. }
  50. foreach (var material in keyMaterials.OrderByDescending(q => q.Value).ThenBy(m => m.Key))
  51. {
  52. Console.WriteLine($"{material.Key}: {material.Value}");
  53. }
  54. foreach (var material in junkMaterials)
  55. {
  56. Console.WriteLine($"{material.Key}: {material.Value}");
  57. }
  58. }
  59. }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment