Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- namespace apps
- {
- class Program
- {
- static string Get() { return Console.ReadLine(); }
- static void Main()
- {
- SortedDictionary<string, int> collection = new SortedDictionary<string, int>();
- bool FoundLegendary = false;
- while (FoundLegendary == false)
- {
- string input = Get();
- string[] parts = input.Split(' ').ToArray();
- for (int i = 1; i < 6; i += 2)
- {
- string resource = parts[i].ToLower();
- int value = int.Parse(parts[i - 1]);
- if (collection.ContainsKey(resource)) { collection[resource] += value; }
- else { collection.Add(resource, value); }
- }
- if (collection.ContainsKey("shards"))
- {
- if (collection["shards"] >= 250)
- {
- collection["shards"] -= 250;
- Console.WriteLine("Shadowmourne obtained!");
- FoundLegendary = true;
- }
- }
- if (collection.ContainsKey("fragments"))
- {
- if (collection["fragments"] >= 250)
- {
- collection["fragments"] -= 250;
- Console.WriteLine("Valanyr obtained!");
- FoundLegendary = true;
- }
- }
- if (collection.ContainsKey("motes"))
- {
- if (collection["motes"] >= 250)
- {
- collection["motes"] -= 250;
- Console.WriteLine("Dragonwrath obtained!");
- FoundLegendary = true;
- }
- }
- }
- collection.OrderByDescending(i => i.Value);
- collection.OrderBy(i => i.Key);
- foreach (var v in collection)
- {
- Console.WriteLine($"{v.Key}: {v.Value}");
- }
- }// END MAIN
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement