Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace _09_Legendary_Farming
- {
- public class LegendaryFarming
- {
- public static void Main()
- {
- var input = Console.ReadLine().ToLower().Split().ToArray();
- Dictionary<string, int> dict = new Dictionary<string, int>();
- Dictionary<string, int> junkItems = new Dictionary<string, int>();
- dict["shards"] = 0;
- dict["fragments"] = 0;
- dict["motes"] = 0;
- int cnt = 1;
- while (cnt != 10)
- {
- for (int i = 0; i < input.Length - 1; i += 2)
- {
- int quantity = int.Parse(input[i]);
- string material = input[i + 1];
- if (material == "shards")
- {
- dict["shards"] += quantity;
- }
- else if (material == "fragments")
- {
- dict["fragments"] += quantity;
- }
- else if (material == "motes")
- {
- dict["motes"] += quantity;
- }
- else
- {
- if (!junkItems.ContainsKey(material))
- {
- junkItems[material] = 0;
- }
- junkItems[material] += quantity;
- }
- if (dict["shards"] >= 250)
- {
- dict["shards"] -= 250;
- Console.WriteLine("Shadowmourne obtained!");
- PrintResult(dict, junkItems);
- return;
- }
- else if (dict["fragments"] >= 250)
- {
- dict["fragments"] -= 250;
- Console.WriteLine("Valanyr obtained!");
- PrintResult(dict, junkItems);
- return;
- }
- else if (dict["motes"] >= 255)
- {
- dict["motes"] -= 250;
- Console.WriteLine("Dragonwrath obtained!");
- PrintResult(dict, junkItems);
- return;
- }
- }
- cnt++;
- input = Console.ReadLine().ToLower().Split().ToArray();
- }
- }
- static void PrintResult(Dictionary<string, int> dict, Dictionary<string, int> junkItems)
- {
- foreach (var pair in dict.OrderByDescending(x => x.Value).ThenBy(x => x.Key))
- {
- Console.WriteLine($"{pair.Key}: {pair.Value}");
- }
- foreach (var pair in junkItems.OrderBy(x => x.Key))
- {
- Console.WriteLine($"{pair.Key}: {pair.Value}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement