Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- namespace Fallowers
- {
- class Program
- {
- static void Main(string[] args)
- {
- Dictionary<string, List<int>> users = new Dictionary<string, List<int>>();
- while (true)
- {
- string command = Console.ReadLine();
- if (command== "Log out")
- {
- break;
- }
- string[] tokens = command.Split(':').ToArray();
- string name = tokens[1];
- if (tokens[0]== "New follower")
- {
- if (!users.ContainsKey(name))
- {
- users.Add(name, new List<int>());
- users[name].Add(0);
- users[name].Add(0);
- }
- }
- else if (tokens[0] == "Like")
- {
- if (!users.ContainsKey(name))
- {
- users.Add(name, new List<int>());
- users[name].Add(0);
- users[name].Add(0);
- users[name][0] += int.Parse(tokens[2]);
- }
- else
- {
- users[name][0] += int.Parse(tokens[2]);
- }
- }
- else if (tokens[0] == "Comment")
- {
- if (!users.ContainsKey(name))
- {
- users.Add(name, new List<int>());
- users[name].Add(0);
- users[name].Add(0);
- users[name][1] += 1;
- }
- else
- {
- users[name][1] += 1;
- }
- }
- else if (tokens[0] == "Blocked")
- {
- if (!users.ContainsKey(name))
- {
- Console.WriteLine($"{name} doesn't exist.");
- }
- else
- {
- users.Remove(name);
- }
- }
- }
- Console.WriteLine($"{users.Count} followers");
- users.OrderBy(n => n.Key).ThenByDescending(v=>v.Value.Sum());
- foreach (var name in users.Keys)
- {
- int total = users[name][0] += users[name][1];
- foreach (var list in users[name])
- {
- Console.WriteLine($"{name}: {total}");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement