Advertisement
Pazzobg

Exam FEB17 04.HornetArmada

Jul 5th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.23 KB | None | 0 0
  1. namespace _04.HornetArmada
  2. {
  3.     using System;
  4.     using System.Collections.Generic;
  5.     using System.Linq;
  6.     using System.Text;
  7.     using System.Threading.Tasks;
  8.     using System.Text.RegularExpressions;
  9.  
  10.     public class Legion
  11.     {
  12.         public string Name { get; set; }
  13.  
  14.         public int LastActivity { get; set; }
  15.  
  16.         public Dictionary<string, long> SoldiersTypes { get; set; }
  17.     }
  18.  
  19.     public class HornetArmada
  20.     {
  21.         public static void Main()
  22.         {
  23.             var legions = new Dictionary<string, Legion>();
  24.  
  25.             int n = int.Parse(Console.ReadLine());
  26.  
  27.             for (int i = 0; i < n; i++)
  28.             {
  29.                 string[] input = Console.ReadLine().Split(" =->:".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
  30.                 int lastActivity = int.Parse(input[0]);
  31.                 string legionName = input[1];
  32.                 string soldierType = input[2];
  33.                 long soldierCount = long.Parse(input[3]);
  34.  
  35.                 var currentLegion = new Legion
  36.                 {
  37.                     Name = legionName,
  38.                     LastActivity = lastActivity,
  39.                     SoldiersTypes = new Dictionary<string, long>()
  40.                 };
  41.  
  42.                 if (!legions.ContainsKey(legionName))
  43.                 {
  44.                     legions[legionName] = currentLegion;
  45.                 }
  46.  
  47.                 if (!legions[legionName].SoldiersTypes.ContainsKey(soldierType))
  48.                 {
  49.                     legions[legionName].SoldiersTypes[soldierType] = 0;
  50.                 }
  51.  
  52.                 legions[legionName].SoldiersTypes[soldierType] += soldierCount;
  53.  
  54.                 if (legions.ContainsKey(legionName) && lastActivity > legions[legionName].LastActivity)
  55.                 {
  56.                     legions[legionName].LastActivity = lastActivity;
  57.                 }
  58.             }
  59.  
  60.             string command = Console.ReadLine();
  61.  
  62.             if (command.Contains(@"\"))
  63.             {
  64.                 string[] input = command.Split("\\".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
  65.                 int lastActivity = int.Parse(input[0]);
  66.                 string soldierType = input[1];
  67.  
  68.  
  69.             }
  70.  
  71.         }
  72.     }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement