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 _01.Files
- {
- class files
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- Dictionary<string, int> Data = new Dictionary<string, int>();
- List<string> directories = new List<string>();
- for (int i = 0; i < n; i++)
- {
- string line = Console.ReadLine();
- directories.Add(line);
- }
- string search = Console.ReadLine();
- string[] tokens = search.Split();
- string extension = tokens[0];
- string folder = tokens[2];
- foreach (var directory in directories)
- {
- string[] param = directory.Split('\\');
- string currentFolder = param[0];
- string currentExtension = param[param.Length - 1];
- if (currentFolder.Contains(folder) && currentExtension.Contains(extension))
- {
- string[] token = currentExtension.Split(';');
- string name = token[0];
- int memory = int.Parse(token[1]);
- if (!Data.ContainsKey(name))
- {
- Data[name] = 0;
- }
- Data[name] = memory;
- }
- }
- if (Data.Count==0)
- {
- Console.WriteLine("No");
- return;
- }
- foreach (var item in Data.OrderByDescending(a=>a.Value).ThenBy(a=>a.Key))
- {
- Console.WriteLine($"{item.Key} - {item.Value} KB ");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement