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;
- using System.Numerics;
- namespace _3.TaskThree
- {
- class TaskThree
- {
- static void Main(string[] args)
- {
- Dictionary<string, Dictionary<string, BigInteger>> dataSetsDictionary = new Dictionary<string, Dictionary<string, BigInteger>>();
- while (true)
- {
- string[] input = Console.ReadLine()
- .Split(new string[] { " -> ", " | " }
- , StringSplitOptions.RemoveEmptyEntries);
- if (input[0] == "thetinggoesskrra")
- {
- break;
- }
- else if (input.Length < 3)
- {
- continue;
- }
- else
- {
- if (input.Length != 1 && input.Length != 0)
- {
- string dataKey = input[0];
- BigInteger dataSize = BigInteger.Parse(input[1]);
- string dataSet = input[2];
- if (!dataSetsDictionary.ContainsKey(dataSet))
- {
- dataSetsDictionary.Add(dataSet, new Dictionary<string, BigInteger>());
- dataSetsDictionary[dataSet].Add(dataKey, dataSize);
- }
- else if (dataSetsDictionary.ContainsKey(dataSet))
- {
- dataSetsDictionary[dataSet].Add(dataKey, dataSize);
- }
- }
- else
- {
- continue;
- }
- }
- }
- //PrinTing:
- var dataSetAndDataSize = new Dictionary<string, BigInteger>();
- foreach (var token in dataSetsDictionary)
- {
- foreach (var items in token.Value)
- {
- if (!dataSetAndDataSize.ContainsKey(token.Key))
- {
- dataSetAndDataSize.Add(token.Key, items.Value);
- }
- else if (dataSetAndDataSize.ContainsKey(token.Key))
- {
- dataSetAndDataSize[token.Key] += items.Value;
- }
- }
- }
- var biggestDataSize = dataSetAndDataSize.OrderByDescending(z => z.Value).ToDictionary(pair => pair.Key, pair => pair.Value);
- Console.WriteLine(@"Data Set: {0}, Total Size: {1}", biggestDataSize.Keys.First(), biggestDataSize.Values.First());
- foreach (var items in dataSetsDictionary)
- {
- foreach (var tokens in items.Value)
- {
- if (items.Key == biggestDataSize.Keys.First())
- {
- Console.WriteLine(@"$.{0}", tokens.Key);
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement