Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- namespace DragonArmy
- {
- class Program
- {
- static void Main()
- {
- int n = int.Parse(Console.ReadLine());
- var dragons = new Dictionary<string, SortedDictionary<string, List<int>>>();
- for (int i = 0; i < n; i++)
- {
- string[] tokens = Console.ReadLine().Split(" ");
- string type = tokens[0];
- string name = tokens[1];
- int damage = tokens[2] == "null" ? 45 : int.Parse(tokens[2]);
- int health = tokens[3] == "null" ? 250 : int.Parse(tokens[3]);
- int armor = tokens[4] == "null" ? 10 : int.Parse(tokens[4]);
- if (!dragons.ContainsKey(type))
- {
- dragons.Add(type, new SortedDictionary<string, List<int>>());
- }
- dragons[type][name] = new List<int>{ damage, health, armor};
- }
- foreach (var type in dragons)
- {
- double[] averageType = new double[3];
- for (int i = 0; i < 3; i++)
- {
- averageType[i] = type.Value.Values.Select(x => x[i]).Average();
- }
- Console.WriteLine($"{type.Key}::({averageType[0]:f2}/{averageType[1]:f2}/{averageType[2]:f2})");
- foreach (var dragon in type.Value)
- {
- Console.WriteLine($"-{dragon.Key} -> damage: {dragon.Value[0]}, health: {dragon.Value[1]}, armor: {dragon.Value[2]}");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement