Guest User

Untitled

a guest
Nov 4th, 2017
125
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace _04.Files
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. int n = int.Parse(Console.ReadLine());
  12. Dictionary<string, Dictionary<string, long>> fileDirectory = new Dictionary<string, Dictionary<string, long>>();
  13.  
  14. for (int i = 0; i < n; i++)
  15. {
  16. string[] path = Console.ReadLine().Split('\\');
  17. string rootDir = path[0];
  18. string[] fileInfo = path[path.Length - 1].Split(new char[] { ';'}, StringSplitOptions.RemoveEmptyEntries);
  19. string file = fileInfo[0];
  20. long size = long.Parse(fileInfo[fileInfo.Length-1]);
  21. if (!fileDirectory.ContainsKey(rootDir))
  22. {
  23. fileDirectory.Add(rootDir, new Dictionary<string, long>());
  24. }
  25.  
  26. if (!fileDirectory[rootDir].ContainsKey(file))
  27. {
  28. fileDirectory[rootDir].Add(file, 0);
  29. }
  30.  
  31. fileDirectory[rootDir][file] = size;
  32. }
  33.  
  34. string[] query = Console.ReadLine().Split(' ');
  35.  
  36. string whereToSearch = query[2];
  37. string extention = query[0];
  38. bool contains = false;
  39. foreach (var root in fileDirectory.Where(x => x.Key == whereToSearch))
  40. {
  41. foreach (var file in root.Value.OrderByDescending(x => x.Value).ThenBy(x => x.Key))
  42. {
  43.  
  44. if (file.Key.Contains($".{extention}"))
  45. {
  46. contains = true;
  47. Console.WriteLine($"{file.Key} - {file.Value} KB");
  48. }
  49. }
  50. }
  51.  
  52. if (!contains)
  53. {
  54. Console.WriteLine("No");
  55. }
  56.  
  57. }
  58. }
  59. }
RAW Paste Data