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 ActivityTracker_13
- {
- class ActivityTracker_13
- {
- static void Main(string[] args)
- {
- SortedDictionary<int, SortedDictionary<string, int>> spyData = new SortedDictionary<int, SortedDictionary<string, int>>();
- SortedDictionary<string, int> userData = new SortedDictionary<string, int>();
- int n = int.Parse(Console.ReadLine());
- for (int a = 0; a < n; a++)
- {
- string[] inputData = Console.ReadLine().Split();
- DateTime date = DateTime.Parse(inputData[0]);
- int month = date.Month;
- string userName = inputData[1];
- int distance = int.Parse(inputData[2]);
- if (!spyData.ContainsKey(month))
- {
- userData = new SortedDictionary<string, int>();
- userData.Add(userName, distance);
- spyData.Add(month, userData);
- }
- else
- {
- if (!userData.ContainsKey(userName))
- {
- userData.Add(userName, distance);
- }
- else
- {
- int currentDist = userData[userName];
- int newDistance = currentDist + distance;
- userData[userName] = newDistance;
- }
- spyData[month] = userData;
- }
- }
- foreach (var k in spyData.Keys)
- {
- Console.Write(k+":");
- SortedDictionary<string, int> data = spyData[k];
- foreach (var c in data)
- {
- Console.Write("{0} ({1}),",c.Key, c.Value);
- }
- Console.WriteLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement