Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- namespace LogsAggregator
- {
- class Program
- {
- public static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- //var input = Console.ReadLine().Split(' ').ToArray();
- var logsAgregator = new SortedDictionary<string, SortedDictionary<string,int>>();
- for (int i = 0; i < n; i++)
- {
- var input = Console.ReadLine().Split(' ').ToArray();
- string user = input[1];
- int duration = int.Parse(input[2]);
- string ip = input[0];
- if (logsAgregator.ContainsKey(user))
- {
- if (logsAgregator[user].ContainsKey(ip))
- {
- logsAgregator[user][ip] += duration;
- }
- else
- {
- logsAgregator[user].Add(ip, duration);
- }
- }
- else
- {
- logsAgregator.Add(user, new SortedDictionary<string, int> {{ip, duration}});
- }
- }
- foreach (var userName in logsAgregator)
- {
- var name = userName.Key;
- var ipsDuration = userName.Value; //TOVA E DICT
- var totalDuration = ipsDuration.Sum(y=>y.Value);
- var ipsTotal = ipsDuration.Select(y=>y.Keys).ToList();
- }
- Console.WriteLine("{0}: {1} ")
- Console.Write("Press any key to continue . . . ");
- Console.ReadKey(true);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement