Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Numerics;
- using System.Collections.Generic;
- using System.Runtime.CompilerServices;
- namespace AnonymousCache
- {
- class Program
- {
- static void Main(string[] args)
- {
- Dictionary<string, Dictionary<string, long>> dataSets = new Dictionary<string, Dictionary<string, long>>();
- Dictionary<string, Dictionary<string, long>> cached = new Dictionary<string, Dictionary<string, long>>();
- BigInteger total = 0;
- while (true)
- {
- string input = Console.ReadLine();
- if (input == String.Empty)
- {
- continue;
- }
- if (input == "thetinggoesskrra")
- {
- foreach (var set in dataSets)
- {
- foreach (var cset in cached)
- {
- foreach (var c in cset.Value)
- {
- if (set.Key == cset.Key)
- {
- dataSets[set.Key].Add(c.Key, c.Value);
- }
- }
- }
- }
- foreach (var s in dataSets.OrderByDescending(x => x.Value.Values.Sum()))
- {
- foreach (var q in s.Value)
- {
- total += q.Value;
- }
- Console.WriteLine($"Data Set: {s.Key}, Total Size: {total}");
- foreach (var z in s.Value)
- {
- Console.WriteLine($"$.{z.Key}");
- }
- break;
- }
- break;
- }
- string[] token = input
- .Split(new char[] {' ', '-', ';', '>', '|'}, StringSplitOptions.RemoveEmptyEntries)
- .ToArray();
- if (token.Length > 1)
- {
- string dataKey = token[0];
- long dataSize = long.Parse(token[1]);
- string dataSet = token[2];
- if (!cached.ContainsKey(dataSet))
- {
- cached.Add(dataSet, new Dictionary<string, long>());
- cached[dataSet].Add(dataKey, dataSize);
- }
- else
- {
- if (!cached[dataSet].ContainsKey(dataKey))
- {
- cached[dataSet].Add(dataKey, dataSize);
- }
- }
- }
- else
- {
- if (!dataSets.ContainsKey(token[0]))
- {
- dataSets.Add(token[0], new Dictionary<string, long>());
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement