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;
- using System.Threading.Tasks;
- namespace friendsFromRainyUniverse
- {
- class Program
- {
- static void Main(string[] args)
- {
- var input = Console.ReadLine().Split(new char[] { ' ', '-', '>', ':' }, StringSplitOptions.RemoveEmptyEntries);
- var result = new SortedDictionary<string, Dictionary<string, int>>();
- string personName = input[0];
- string liquidName = input[1];
- int jarCount = int.Parse(input[2]);
- while (input[0] != "End")
- {
- personName = input[0];
- liquidName = input[1];
- jarCount = int.Parse(input[2]);
- if (!result.ContainsKey(personName))
- {
- result.Add(personName, new Dictionary<string, int>());
- }
- if (!result[personName].ContainsKey(liquidName))
- {
- result[personName].Add(liquidName, 0);
- }
- result[personName][liquidName] += jarCount;
- input = Console.ReadLine().Split(new char[] { ' ', '-', '>', ':' }, StringSplitOptions.RemoveEmptyEntries);
- }
- foreach (var person in result)
- {
- Console.WriteLine($"{person.Key} Liquids:");
- foreach (var liquid in person.Value.OrderBy(l => l.Value))
- {
- Console.WriteLine($"--- {liquid.Key}: { liquid.Value}");
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment