Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace _09Problem_LegendaryFarming
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<string> quantityAndMaterial = Console.ReadLine().Split(' ').ToList();
- int foundShards = 0;
- int foundFragments = 0;
- int foundMotes = 0;
- var remainingKeyMaterials = new Dictionary<string, int>(){{"shards", 0}, {"fragments", 0}, {"motes", 0}};
- var availableJunk = new SortedDictionary<string, long>();
- string foundItem = "";
- while (foundShards < 250 && foundFragments < 250 && foundMotes < 250)
- {
- int quantity = int.Parse(quantityAndMaterial[0]);
- string material = quantityAndMaterial[1];
- switch (material.ToLower())
- {
- case "shards":
- foundShards += quantity;
- if (foundShards >= 250)
- {
- foundItem += "Shadowmourne";
- }
- remainingKeyMaterials["shards"] += quantity;
- break;
- case "fragments":
- foundFragments += quantity;
- if (foundFragments >= 250)
- {
- foundItem += "Valanyr";
- }
- remainingKeyMaterials["fragments"] += quantity;
- break;
- case "motes":
- foundMotes += quantity;
- if (foundMotes >= 250)
- {
- foundItem += "Dragonwrath";
- }
- remainingKeyMaterials["motes"] += quantity;
- break;
- default:
- if (availableJunk.ContainsKey(material) == false)
- {
- availableJunk.Add(material, quantity);
- }
- else
- {
- availableJunk[material] += quantity;
- }
- break;
- }
- quantityAndMaterial.RemoveRange(0, 2);
- if (quantityAndMaterial.Count == 0)
- {
- quantityAndMaterial = Console.ReadLine().Split(' ').ToList();
- }
- }
- if (foundItem.Equals("Shadowmourne"))
- {
- remainingKeyMaterials["shards"] -= 250;
- }
- else if (foundItem.Equals("Valanyr"))
- {
- remainingKeyMaterials["fragments"] -= 250;
- }
- else
- {
- remainingKeyMaterials["motes"] -= 250;
- }
- Console.WriteLine(foundItem + " obtained!");
- foreach (var keyMaterialKV in remainingKeyMaterials.OrderByDescending(x => x.Value).ThenBy(x => x.Key))
- {
- Console.WriteLine($"{keyMaterialKV.Key}: {keyMaterialKV.Value}");
- }
- foreach (var junkKV in availableJunk)
- {
- Console.WriteLine($"{junkKV.Key}: {junkKV.Value}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement