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 ConsoleApp115
- {
- class Program
- {
- static void Main(string[] args)
- {
- Dictionary<string, long> data = new Dictionary<string, long>();
- int n = int.Parse(Console.ReadLine());
- List<string> values = new List<string>();
- for (int i = 0; i < n; i++)
- {
- string info = Console.ReadLine();
- values.Add(info);
- }
- string[] lookFor = Console.ReadLine()
- .Split(new string[] { " in " }, StringSplitOptions.RemoveEmptyEntries)
- .ToArray();
- string extention = lookFor[0];
- string root = lookFor[1];
- foreach (var item in values)
- {
- var dotSplit = item.Substring(item.LastIndexOf('.') + 1);
- if (item.StartsWith(root) && dotSplit.StartsWith(extention))
- {
- string output = item.Substring(item.LastIndexOf('\\') + 1);
- string[] splitOutput = output.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries).ToArray();
- string filenameAndExtention = splitOutput[0];
- long size = long.Parse(splitOutput[1]);
- if (!data.ContainsKey(filenameAndExtention))
- {
- data.Add(filenameAndExtention, size);
- }
- else
- {
- data[filenameAndExtention] = size;
- }
- }
- }
- if (data.Count == 0)
- {
- Console.WriteLine("No");
- }
- else
- {
- foreach (var file in data.OrderByDescending(a => a.Value).ThenBy(a => a.Key))
- {
- if(file.Key.StartsWith(" "))
- {
- Console.WriteLine($"{file.Key.Remove(0, 1)} - {file.Value} KB");
- }
- else
- {
- Console.WriteLine($"{file.Key} - {file.Value} KB");
- }
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment