Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- class DragonArmy
- {
- static void Main(string[] args)
- {
- int count = int.Parse(Console.ReadLine());
- var dragons = new Dictionary<string, Dictionary<string, Dragon>>();
- for (int currentDragon = 0; currentDragon < count; currentDragon++)
- {
- string[] input = Console.ReadLine()
- .Split()
- .ToArray();
- string type = input[0];
- string name = input[1];
- int damage = 45;
- int health = 250;
- int armor = 10;
- try
- {
- damage = int.Parse(input[2]);
- }
- catch (Exception) { }
- try
- {
- health = int.Parse(input[3]);
- }
- catch (Exception) { }
- try
- {
- armor = int.Parse(input[4]);
- }
- catch (Exception) { }
- if (dragons.ContainsKey(type) == false)
- {
- dragons.Add(type, new Dictionary<string, Dragon>());
- }
- if (dragons[type].ContainsKey(name) == false)
- {
- dragons[type].Add(name, new Dragon());
- }
- dragons[type][name].damage = damage;
- dragons[type][name].health = health;
- dragons[type][name].armor = armor;
- }
- foreach (var type in dragons)
- {
- double averageDamage = 1.0 * type.Value.Values.Sum(x => x.damage) / type.Value.Count;
- double averageHealth = 1.0 * type.Value.Values.Sum(x => x.health) / type.Value.Count;
- double averageArmor = 1.0 * type.Value.Values.Sum(x => x.armor) / type.Value.Count;
- Console.WriteLine($"{type.Key}::({averageDamage:F2}/{averageHealth:F2}/{averageArmor:F2})");
- foreach (var name in type.Value.OrderBy(x => x.Key))
- {
- Console.WriteLine($"-{name.Key} -> damage: {name.Value.damage}, health: {name.Value.health}, armor: {name.Value.armor}");
- }
- }
- }
- }
- class Dragon
- {
- public int damage { get; set; }
- public int health { get; set; }
- public int armor { get; set; }
- }
Advertisement
Add Comment
Please, Sign In to add comment