Advertisement
miroLLL

09Problem.LegendaryFarming

Feb 15th, 2018
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.42 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace _09Problem_LegendaryFarming
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             List<string> quantityAndMaterial = Console.ReadLine().Split(' ').ToList();
  12.  
  13.             int foundShards = 0;
  14.             int foundFragments = 0;
  15.             int foundMotes = 0;
  16.  
  17.             var remainingKeyMaterials = new Dictionary<string, int>(){{"shards", 0}, {"fragments", 0}, {"motes", 0}};
  18.             var availableJunk = new SortedDictionary<string, long>();
  19.  
  20.             string foundItem = "";
  21.  
  22.             while (foundShards < 250 && foundFragments < 250 && foundMotes < 250)
  23.             {
  24.                 int quantity = int.Parse(quantityAndMaterial[0]);
  25.                 string material = quantityAndMaterial[1];
  26.  
  27.                 switch (material.ToLower())
  28.                 {
  29.                     case "shards":
  30.  
  31.                         foundShards += quantity;
  32.  
  33.                         if (foundShards >= 250)
  34.                         {
  35.                             foundItem += "Shadowmourne";
  36.                         }
  37.  
  38.                         remainingKeyMaterials["shards"] += quantity;
  39.                         break;
  40.  
  41.                     case "fragments":
  42.  
  43.                         foundFragments += quantity;
  44.  
  45.                         if (foundFragments >= 250)
  46.                         {
  47.                             foundItem += "Valanyr";
  48.                         }
  49.  
  50.                         remainingKeyMaterials["fragments"] += quantity;
  51.                         break;
  52.  
  53.                     case "motes":
  54.  
  55.                         foundMotes += quantity;
  56.  
  57.                         if (foundMotes >= 250)
  58.                         {
  59.                             foundItem += "Dragonwrath";
  60.                         }
  61.  
  62.                         remainingKeyMaterials["motes"] += quantity;
  63.                         break;
  64.  
  65.                     default:
  66.                         if (availableJunk.ContainsKey(material) == false)
  67.                         {
  68.                             availableJunk.Add(material, quantity);
  69.                         }
  70.                         else
  71.                         {
  72.                             availableJunk[material] += quantity;
  73.                         }
  74.                         break;
  75.                 }
  76.  
  77.                 quantityAndMaterial.RemoveRange(0, 2);
  78.  
  79.                 if (quantityAndMaterial.Count == 0)
  80.                 {
  81.                     quantityAndMaterial = Console.ReadLine().Split(' ').ToList();
  82.                 }
  83.             }
  84.  
  85.             if (foundItem.Equals("Shadowmourne"))
  86.             {
  87.                 remainingKeyMaterials["shards"] -= 250;
  88.             }
  89.             else if (foundItem.Equals("Valanyr"))
  90.             {
  91.                 remainingKeyMaterials["fragments"] -= 250;
  92.             }
  93.             else
  94.             {
  95.                 remainingKeyMaterials["motes"] -= 250;
  96.             }
  97.  
  98.             Console.WriteLine(foundItem + " obtained!");
  99.  
  100.             foreach (var keyMaterialKV in remainingKeyMaterials.OrderByDescending(x => x.Value).ThenBy(x => x.Key))
  101.             {
  102.                 Console.WriteLine($"{keyMaterialKV.Key}: {keyMaterialKV.Value}");
  103.             }
  104.  
  105.             foreach (var junkKV in availableJunk)
  106.             {
  107.                 Console.WriteLine($"{junkKV.Key}: {junkKV.Value}");
  108.             }
  109.         }
  110.     }
  111. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement