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 Files
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- var rootFileextSize = new Dictionary<string, Dictionary<string, long>>();
- int count = 0;
- for (int i = 0; i < n; i++)
- {
- var input = Console.ReadLine().Split('\\').ToArray();
- string root = input[0];
- string file = input.Last().Split(';')[0];
- long size = long.Parse(input.Last().Split(';')[1]);
- if (!rootFileextSize.ContainsKey(root))
- {
- rootFileextSize.Add(root, new Dictionary<string, long>());
- }
- rootFileextSize[root].Add(file, size);
- }
- var command = Console.ReadLine().Split(' ').ToArray();
- string rootCommand = command[2];
- string extCommand = command[0];
- foreach (var rootFileSize in rootFileextSize.Where(x=> x.Key == rootCommand))
- {
- foreach (var FileSize in rootFileSize.Value)
- {
- if (FileSize.Key.Contains(extCommand))
- {
- count++;
- }
- }
- if (count == 0)
- {
- Console.WriteLine("No");
- return;
- }
- foreach (var FileSize in rootFileSize.Value.Where(x=> x.Key.Contains(extCommand)).OrderByDescending(x=>x.Value).ThenBy(x=> x.Key))
- {
- Console.WriteLine($"{FileSize.Key} - {FileSize.Value} KB");
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment