Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Text.RegularExpressions;
- using System.Collections;
- class ActivityTracker
- {
- static void Main()
- {
- int n = int.Parse(Console.ReadLine());
- string[] input = new string[n];
- List<string> dates = new List<string>();
- List<string> names = new List<string>();
- List<string> distance = new List<string>();
- for (int i = 0; i < n; i++)
- {
- input[i] = Console.ReadLine();
- string[] all = input[i].Split(new char[]{' '}, StringSplitOptions.RemoveEmptyEntries);
- dates.Add(all[0]);
- names.Add(all[1]);
- distance.Add(all[2]);
- }
- string pattern = @"(\d*)\/(\d*)\/(\d*)";
- Regex rgx = new Regex(pattern);
- string[] month = new string[n];
- for (int i = 0; i < n; i++)
- {
- Match mth = rgx.Match(dates[i]);
- month[i] = Convert.ToString(mth.Groups[2]);
- }
- Dictionary<string, Dictionary<string, List<string>>> users = new Dictionary<string, Dictionary<string, List<string>>>();
- for (int i = 0; i < n; i++)
- {
- if (!users.ContainsKey(month[i]))
- {
- users[month[i]] = new Dictionary<string, List<string>>();
- }
- if (!users[month[i]].ContainsKey(names[i]))
- {
- users[month[i]][names[i]] = new List<string>();
- }
- users[month[i]][names[i]].Add(distance[i]);
- }
- int sum = 0;
- foreach (var item in users)
- {
- Console.Write("{0}: ", item.Key);
- foreach (var item2 in item.Value)
- {
- Console.Write("{0}", item2.Key);
- foreach (var item3 in item2.Value)
- {
- int a = int.Parse(item3);
- sum += a;
- }
- Console.Write("({0})", sum);
- sum = 0;
- }
- Console.WriteLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement