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;
- using System.Threading.Tasks;
- namespace RainAir
- {
- class Program
- {
- static void Main(string[] args)
- {
- string input = Console.ReadLine();
- SortedDictionary<string, List<int>> dict = new SortedDictionary<string, List<int>>();
- while (input != "I believe I can fly!")
- {
- string[] arr = input.Split(' ').ToArray();
- if (!arr[0].Contains(' ') || !arr[0].Contains('='))
- {
- if (arr[1] != "=")
- {
- string customerName = arr[0];
- if (!dict.Keys.Contains(customerName))
- {
- dict.Add(customerName, new List<int>());
- dict[customerName].AddRange(arr.Skip(1).Select(x => int.Parse(x)).ToArray());
- }
- else
- {
- dict[customerName].AddRange(arr.Skip(1).Select(x => int.Parse(x)).ToArray());
- }
- }
- else
- {
- dict[arr[0]].Clear();
- dict[arr[0]].AddRange(dict[arr[2]]);
- }
- }
- input = Console.ReadLine();
- }
- //var ordered = dict.OrderByDescending(x => x.Value.Count).ThenBy(y => y.Key);
- foreach (var item in dict.OrderByDescending(x => x.Value.Count))
- {
- Console.Write("#" + item.Key + " ::: ");
- item.Value.Sort();
- Console.WriteLine(string.Join(", ", item.Value));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement