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;
- namespace Logs_Aggregator
- {
- class Program
- {
- static void Main(string[] args)
- {
- int lines = int.Parse(Console.ReadLine());
- List<string[]> data = new List<string[]>();
- for (int i = 0; i < lines; i++)
- {
- string[] input = Console.ReadLine().Split(new char[] {' '}, StringSplitOptions.RemoveEmptyEntries);
- data.Add(input);
- }
- SortedDictionary<string,string> output=new SortedDictionary<string, string>();
- List<string> usedNames=new List<string>();
- for (int i = 0; i < data.Count; i++)
- {
- if (!usedNames.Contains(data[i][1]))
- {
- string name = data[i][1];
- usedNames.Add(name);
- SortedSet<string> ips = new SortedSet<string> ();
- int time = 0;
- for (int j = 0; j < data.Count; j++)
- {
- if (data[j][1] == name)
- {
- if (!ips.Contains(data[j][0]))
- {
- ips.Add(data[j][0]);
- }
- time += int.Parse(data[j][2]);
- }
- }
- StringBuilder sb = new StringBuilder();
- sb.Append(time + " [" + string.Join(", ", ips) + "]");
- output.Add(name+": ",sb.ToString());
- }
- }
- foreach (var val in output)
- {
- Console.WriteLine(val.Key+val.Value);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement