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 _04.Files
- {
- class Program
- {
- static void Main(string[] args)
- {
- Dictionary<string, Dictionary<string, decimal>> dict = new Dictionary<string, Dictionary<string, decimal>>();
- int n = int.Parse(Console.ReadLine());
- for (int i = 0; i < n; i++)
- {
- string input = Console.ReadLine();
- var everything = input.Split('\\').ToList();
- string root = everything[0];
- var fileAndSize = everything[everything.Count - 1].Split(';').ToList();
- string fileName = fileAndSize[0];
- decimal fileSize = long.Parse(fileAndSize[1]);
- if (!dict.ContainsKey(root))
- {
- dict.Add(root, new Dictionary<string, decimal>());
- dict[root].Add(fileName, fileSize);
- }
- else
- {
- if (!dict[root].ContainsKey(fileName))
- {
- dict[root].Add(fileName, fileSize);
- }
- else
- {
- dict[root][fileName] = fileSize;
- }
- }
- }
- SortedDictionary<string, decimal> result = new SortedDictionary<string, decimal>();
- List<string> end = Console.ReadLine().Split(' ').ToList();
- string resultType = "." + end[0];
- string resultRoot = end[2];
- foreach (KeyValuePair<string, Dictionary<string, decimal>> pair in dict)
- {
- if (pair.Key == resultRoot)
- {
- foreach (KeyValuePair<string, decimal> innerpair in dict[pair.Key])
- {
- if (innerpair.Key.Contains(resultType))
- {
- result.Add(innerpair.Key, innerpair.Value);
- }
- }
- }
- }
- if (result.Count == 0)
- {
- Console.WriteLine("No");
- }
- else
- {
- foreach (KeyValuePair<string, decimal> pair in result.OrderByDescending(x => x.Value).ThenBy(x => x.Key))
- {
- Console.WriteLine($"{pair.Key} - {pair.Value} KB");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement