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)
- {
- var keyMaterials = new Dictionary<string, long>()
- {
- {"shards", 0 },
- {"fragments", 0 },
- {"motes", 0 }
- };
- var junkMaterials = new SortedDictionary<string, long>();
- bool keepFarming = true;
- string foundLegendaryItem = "";
- while (keepFarming)
- {
- string[] inputInfo = Console.ReadLine().Split(' ').ToArray();
- for (int i = 0; i < inputInfo.Length; i += 2)
- {
- long quantity = long.Parse(inputInfo[i]);
- string material = inputInfo[i + 1];
- switch (material.ToLower())
- {
- case "shards":
- keyMaterials["shards"] += quantity;
- if (keyMaterials["shards"] >= 250)
- {
- foundLegendaryItem = "Shadowmoure";
- keepFarming = false;
- keyMaterials["shards"] -= 250;
- }
- break;
- case "fragments":
- keyMaterials["fragments"] += quantity;
- if (keyMaterials["fragments"] >= 250)
- {
- foundLegendaryItem = "Valanyr";
- keepFarming = false;
- keyMaterials["fragments"] -= 250;
- }
- break;
- case "motes":
- keyMaterials["motes"] += quantity;
- if (keyMaterials["motes"] >= 250)
- {
- foundLegendaryItem = "Dragonwrath";
- keepFarming = false;
- keyMaterials["motes"] -= 250;
- }
- break;
- default:
- if (junkMaterials.ContainsKey(material) == false)
- {
- junkMaterials.Add(material, quantity);
- }
- else
- {
- junkMaterials[material] += quantity;
- }
- break;
- }
- if (keepFarming == false)
- {
- break;
- }
- }
- }
- Console.WriteLine($"{foundLegendaryItem} obtained!");
- foreach (var keyMaterial in keyMaterials.OrderByDescending(x => x.Value).ThenBy(x => x.Key))
- {
- Console.WriteLine($"{keyMaterial.Key}: {keyMaterial.Value}");
- }
- foreach (var junkMaterial in junkMaterials)
- {
- Console.WriteLine($"{junkMaterial.Key}: {junkMaterial.Value}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement