Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- namespace _04HitList
- {
- class Program
- {
- static void Main(string[] args)
- {
- Dictionary<string, Dictionary<string, string>> nameKeysValue = new Dictionary<string, Dictionary<string, string>>();
- int infoIndex = int.Parse(Console.ReadLine());
- while (true)
- {
- string command = Console.ReadLine();
- if(command == "end transmissions")
- {
- break;
- }
- string[] tokens = command.Split("=");
- string name = tokens[0];
- if(!nameKeysValue.ContainsKey(name))
- {
- nameKeysValue.Add(name, new Dictionary<string, string>());
- }
- string[] personData = tokens[1].Split(";").ToArray();
- foreach (var item in personData)
- {
- string[] personKeyAndValue = item.Split(":");
- string key = personKeyAndValue[0];
- string @value = personKeyAndValue[1];
- if(!nameKeysValue[name].ContainsKey(key))
- {
- nameKeysValue[name].Add(key, @value);
- }
- else
- {
- nameKeysValue[name][key] = value;
- }
- }
- }
- string[] finalLine = Console.ReadLine().Split();
- string nameToKill = finalLine[1];
- if(nameKeysValue.ContainsKey(nameToKill))
- {
- int currInfo = 0;
- foreach (var kvp in nameKeysValue)
- {
- string name = kvp.Key;
- if(name == nameToKill)
- {
- Console.WriteLine($"Info on {name}:");
- foreach (var inner in kvp.Value.OrderBy(x=>x.Key))
- {
- string personKey = inner.Key;
- string personValue = inner.Value;
- Console.WriteLine($"---{personKey}: {personValue}");
- currInfo += personKey.Length + personValue.Length;
- }
- }
- }
- Console.WriteLine($"Info index: {currInfo}");
- if(currInfo>=infoIndex)
- {
- Console.WriteLine("Proceed");
- }
- else
- {
- int infoNeeded = infoIndex - currInfo;
- Console.WriteLine($"Need {infoNeeded} more info.");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement