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 Files
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- var fileSize = new Dictionary<string, long>();
- var helpList = new List<string>();
- for (int i = 0; i < n; i++)
- {
- string input = Console.ReadLine();
- var inputHelp = input.Split('\\').ToList();
- string root = input.Split('\\').ToArray()[0];
- string fileextSize = input.Split('\\').ToArray().Last();
- string file = fileextSize.Split(';').ToArray()[0];
- long size = long.Parse(fileextSize.Split(';').ToArray()[1]);
- string rootFoldersFileSize = $@"{root}\{file}\{size}";
- helpList.Add(rootFoldersFileSize);
- }
- var command = Console.ReadLine().Split(' ').ToArray();
- string extCommand = command[0];
- string rootCommand = command[2];
- int count = 0;
- foreach (string item in helpList)
- {
- var rootFileSize = item.Split('\\').ToArray();
- string root = rootFileSize[0];
- string file = rootFileSize[1];
- if (root == rootCommand && file.Substring(Math.Max(0, file.ToString().Length - extCommand.Length)) == extCommand)
- {
- fileSize[file.ToString()] = long.Parse(rootFileSize[2].ToString());
- count++;
- }
- }
- if (count == 0)
- {
- Console.WriteLine("No");
- return;
- }
- foreach (var pair in fileSize.OrderBy(x=>x.Key).OrderByDescending(x => x.Value))
- {
- Console.WriteLine($"{pair.Key} - {pair.Value} KB");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement