Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace _03._Legendary_Farming
- {
- class Program
- {
- static void Main()
- {
- Dictionary<string, int> dict = new Dictionary<string, int>();
- StringBuilder strb = new StringBuilder();
- bool isDone = false;
- while (!isDone)
- {
- string[] words = Console.ReadLine().Split();
- int value = 0;
- string key;
- for (int i = 0; i < words.Length && !isDone; i++)
- {
- if ((i + 1) % 2 != 0)
- {
- value = int.Parse(words[i]);
- }
- else
- {
- key = words[i].ToLower();
- if (dict.ContainsKey(key))
- {
- dict[key] += value;
- }
- else
- {
- dict.Add(key, value);
- }
- if (dict[key] > 249 && (key == "shards" || key == "fragments" || key == "motes"))
- {
- if (key == "shards")
- {
- strb.AppendLine("Shadowmourne obtained!");
- }
- else if (key == "fragments")
- {
- strb.AppendLine("Valanyr obtained!");
- }
- else
- {
- strb.AppendLine("Dragonwrath obtained!");
- }
- dict[key] -= 250;
- isDone = true;
- }
- }
- }
- }
- if (!dict.ContainsKey("fragments"))
- {
- dict.Add("fragments", 0);
- }
- else if (!dict.ContainsKey("shards"))
- {
- dict.Add("shards", 0);
- }
- else if (!dict.ContainsKey("motes"))
- {
- dict.Add("motes", 0);
- }
- var keyMaterials = dict.Where(x => x.Key == "shards" || x.Key == "fragments" || x.Key == "motes")
- .OrderByDescending(x => x.Value).ThenBy(x => x.Key).ToDictionary(x => x.Key, y => y.Value);
- foreach (var item in keyMaterials)
- {
- strb.AppendLine($"{item.Key}: {item.Value}");
- dict.Remove(item.Key);
- }
- var junkDict = dict.OrderBy(x => x.Key).ToDictionary(x => x.Key, y => y.Value);
- foreach (var item in junkDict)
- {
- strb.AppendLine($"{item.Key}: {item.Value}");
- }
- Console.WriteLine(strb.ToString());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement