Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- namespace Legendary
- {
- class Program
- {
- static void Main(string[] args)
- {
- SortedDictionary<string, int> neededItems = new SortedDictionary<string, int>() { {"shards" , 0} , {"fragments" , 0}, {"motes" , 0} };
- SortedDictionary<string, int> trashItems = new SortedDictionary<string, int>();
- List<int> quantity = new List<int>();
- List<string> namesOfMaterials = new List<string>();
- string legendaryItem = String.Empty;
- bool end = true;
- while (end)
- {
- var input = Console.ReadLine().Split(" ").ToArray();
- int quantityOfMaterial = 0;
- for (int i = 0; i < input.Length; i+=2)
- {
- quantityOfMaterial = int.Parse(input[i]);
- quantity.Add(quantityOfMaterial);
- }
- for (int i = 1; i < input.Length; i+=2)
- {
- var name = input[i].ToLower();
- namesOfMaterials.Add(name);
- }
- for (int i = 0; i < namesOfMaterials.Count; i++)
- {
- if (neededItems.ContainsKey(namesOfMaterials[i]))
- {
- neededItems[namesOfMaterials[i]] += quantity[i];
- if (neededItems[namesOfMaterials[i]] >= 250)
- {
- neededItems[namesOfMaterials[i]] -= 250;
- legendaryItem = namesOfMaterials[i];
- if (legendaryItem == "fragments")
- {
- legendaryItem = "Valanyr obtained!";
- }
- else if (legendaryItem == "shards")
- {
- legendaryItem = "Shadowmourne obtained!";
- }
- else
- {
- legendaryItem = "Dragonwrath obtained!";
- }
- end = false;
- break;
- }
- }
- else if (trashItems.ContainsKey(namesOfMaterials[i]) == false)
- {
- trashItems.Add(namesOfMaterials[i], quantity[i]);
- }
- else if (trashItems.ContainsKey(namesOfMaterials[i]))
- {
- trashItems[namesOfMaterials[i]] += quantity[i];
- }
- }
- namesOfMaterials.Clear();
- quantity.Clear();
- }
- Console.WriteLine(legendaryItem);
- foreach (var item in neededItems.OrderByDescending(c => c.Value))
- {
- Console.WriteLine($"{item.Key}: {item.Value}");
- }
- foreach (var item in trashItems)
- {
- Console.WriteLine($"{item.Key}: {item.Value}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement