Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- class Program
- {
- static void Main()
- {
- int number = int.Parse(Console.ReadLine());
- SortedDictionary<string, double> authorSales = new SortedDictionary<string, double>();
- for (int i = 0; i < number; i++)
- {
- string[] input = Console.ReadLine().Split(' ');
- string author = input[1];
- double price = Convert.ToDouble(input[5]);
- if (authorSales.Keys.Contains(author))
- {
- authorSales[author] += price;
- }
- else
- {
- authorSales.Add(author, price);
- }
- }
- IOrderedEnumerable<KeyValuePair<string, double>> sortedDict = authorSales.OrderByDescending(x => x.Value).ThenBy(x => x.Key);
- foreach (KeyValuePair<string, double> kvp in sortedDict)
- {
- Console.WriteLine("{0} -> {1:F2}", kvp.Key, kvp.Value);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement