Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace Files
- {
- class Program
- {
- static void Main(string[] args)
- {
- var n = int.Parse(Console.ReadLine());
- var files = new Dictionary<string, Dictionary<string, Dictionary<string, decimal>>>();
- while (n-- > 0)
- {
- var tokens = Console.ReadLine().Split(';');
- var fileSize = decimal.Parse(tokens[1]);
- var path = tokens[0].Split('\\');
- var fileRoot = path[0];
- var fileName = path[path.Length - 1];
- var fileExtension = fileName.Split('.').Last();
- if (!files.ContainsKey(fileRoot))
- {
- files[fileRoot] = new Dictionary<string, Dictionary<string, decimal>>();
- files[fileRoot][fileExtension] = new Dictionary<string, decimal>();
- }
- if (!files[fileRoot].ContainsKey(fileExtension))
- {
- files[fileRoot][fileExtension] = new Dictionary<string, decimal>();
- }
- files[fileRoot][fileExtension][fileName] = fileSize;
- }
- var last = Console.ReadLine().Split(' ');
- var extension = last.First();
- var root = last.Last();
- try
- {
- foreach (var nameSizePair in files[root][extension]
- .OrderByDescending(f => f.Value)
- .ThenBy(f => f.Key))
- {
- Console.WriteLine($"{nameSizePair.Key} - {nameSizePair.Value} KB");
- }
- }
- catch
- {
- Console.WriteLine("No");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement