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.Numerics;
- namespace Files
- {
- public class Files
- {
- public static void Main()
- {
- var lines = int.Parse(Console.ReadLine());
- var result = new Dictionary<string, Dictionary<string, BigInteger>>();
- for (int i = 0; i < lines; i++)
- {
- var currentFile = Console.ReadLine().Split('\\', ';').ToArray();
- var root = currentFile[0];
- var file = currentFile[currentFile.Length - 2];
- var fileSize = currentFile.Last();
- if (!result.ContainsKey(root))
- {
- result[root] = new Dictionary<string, BigInteger>();
- }
- if (!result[root].ContainsKey(file))
- {
- result[root][file] = BigInteger.Parse(fileSize);
- }
- if (result[root].ContainsKey(file))
- {
- result[root][file] = BigInteger.Parse(fileSize);
- }
- }
- var condition = Console.ReadLine().Split();
- var directory = condition.Last();
- var searchExtension = condition[0];
- var extension = string.Empty;
- var directoryCounter = 0;
- var count = 0;
- foreach (var root in result.Where(x => x.Key == directory))
- {
- foreach (var fail in root.Value.OrderByDescending(x => x.Value).ThenBy(x => x.Key))
- {
- directoryCounter++;
- var fileWithExt = fail.Key.Split('.').ToArray();
- extension = fileWithExt.Last();
- if (searchExtension == extension)
- {
- Console.WriteLine($"{fail.Key} - {fail.Value} KB");
- }
- else
- {
- count++;
- }
- }
- }
- if (count==directoryCounter)
- {
- Console.WriteLine("No");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement