Advertisement
Guest User

Untitled

a guest
Jul 18th, 2015
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.77 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ActivityTracker
  8. {
  9.     class ActivityTracker
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int n = int.Parse(Console.ReadLine());
  14.             SortedDictionary<int, SortedDictionary<string, decimal>> collection = new SortedDictionary<int, SortedDictionary<string, decimal>>();
  15.             for (int i = 0; i < n; i++)
  16.             {
  17.                 string[] input = Console.ReadLine().Split();
  18.                 string[] datetime = input[0].Split('/');
  19.                 int month = int.Parse(datetime[1]);
  20.                 if (collection.ContainsKey(month))
  21.                 {
  22.                     if (collection[month].ContainsKey(input[1]))
  23.                     {
  24.                         collection[month][input[1]] += decimal.Parse(input[2]);
  25.                     }
  26.                     else
  27.                     {
  28.                         collection[month].Add(input[1], decimal.Parse(input[2]));
  29.                     }
  30.                 }
  31.                 else
  32.                 {
  33.                     collection.Add(month, new SortedDictionary<string, decimal>());
  34.                     collection[month].Add(input[1], int.Parse(input[2]));
  35.                 }
  36.             }
  37.             foreach (var item1 in collection)
  38.             {
  39.                 Console.Write("{0}: ", item1.Key);
  40.                 List<string> temp = new List<string>();
  41.                 foreach (var item2 in item1.Value)
  42.                 {
  43.                     string xx = "" + item2.Key + "(" + item2.Value + ")";
  44.                     temp.Add(xx);
  45.                 }
  46.                 Console.WriteLine("{0}", String.Join(", ", temp));
  47.             }
  48.         }
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement