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 DictionaryLab
- {
- class Program
- {
- static void Main(string[] args)
- {
- Dictionary<string, Dictionary<string, long>> allData = new Dictionary<string, Dictionary<string, long>>();
- Dictionary<string, Dictionary<string, long>> cacheData = new Dictionary<string, Dictionary<string, long>>();
- List<string> dataSetList = new List<string>();
- List<string> inputData = Console.ReadLine().Split(new char[] { ' ', '-', '>', '|' }, StringSplitOptions.RemoveEmptyEntries).ToList();
- while (inputData[0] != "thetinggoesskrra")
- {
- if (inputData.Count == 1)
- {
- string dataSet = inputData[0];
- dataSetList.Add(dataSet);
- if (cacheData.ContainsKey(dataSet))
- {
- foreach (var data in cacheData)
- {
- allData.Add(data.Key, data.Value);
- }
- cacheData.Remove(dataSet);
- }
- }
- else
- {
- string dataKey = inputData[0];
- long dataSize = long.Parse(inputData[1]);
- string dataSet = inputData[2];
- if (dataSetList.Contains(dataSet))
- {
- if (!allData.ContainsKey(dataSet))
- {
- allData[dataSet] = new Dictionary<string, long>();
- allData[dataSet][dataKey] = dataSize;
- }
- else
- {
- allData[dataSet][dataKey] = dataSize;
- }
- }
- else
- {
- if (!cacheData.ContainsKey(dataSet))
- {
- cacheData[dataSet] = new Dictionary<string, long>();
- cacheData[dataSet][dataKey] = dataSize;
- }
- else
- {
- cacheData[dataSet][dataKey] = dataSize;
- }
- }
- }
- inputData = Console.ReadLine().Split(new char[] { ' ', '-', '>', '|' }, StringSplitOptions.RemoveEmptyEntries).ToList();
- }
- if (dataSetList.Count > 0)
- {
- long sum = 0;
- long bestsum = long.MinValue;
- string bestDataset = string.Empty;
- foreach (var dataKeyEl in allData)
- {
- foreach (var dataSet in dataKeyEl.Value)
- {
- sum += dataSet.Value;
- }
- if (sum > bestsum)
- {
- bestsum = sum;
- bestDataset = dataKeyEl.Key;
- }
- sum = 0;
- }
- Console.WriteLine($"Data Set: {bestDataset}, Total Size: {bestsum}");
- foreach (var item in allData)
- {
- if (item.Key == bestDataset)
- {
- foreach (var element in item.Value)
- {
- Console.WriteLine($"$.{element.Key}");
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment