fork download
  1. namespace _11.Dragon_Army
  2. {
  3. using System;
  4. using System.Linq;
  5. using System.Collections.Generic;
  6.  
  7. public class Program
  8. {
  9. public static void Main()
  10. {
  11. var linesCount = int.Parse(Console.ReadLine());
  12.  
  13. var dragonsData = new Dictionary<string, SortedDictionary<string, int[]>>();
  14. var dragonStats = new Dictionary<string, int>();
  15.  
  16. for (int i = 0; i < linesCount; i++)
  17. {
  18. var input = Console.ReadLine();
  19.  
  20. var splittedInput = input.Split(' ').ToArray();
  21.  
  22. var dragonType = splittedInput[0];
  23. var dragonName = splittedInput[1];
  24. var damage = splittedInput[2] == "null" ? 45 : int.Parse(splittedInput[2]);
  25. var health = splittedInput[3] == "null" ? 250 : int.Parse(splittedInput[3]);
  26. var armor = splittedInput[4] == "null" ? 10 : int.Parse(splittedInput[4]);
  27.  
  28. if (!dragonsData.ContainsKey(dragonType))
  29. {
  30. dragonsData[dragonType] = new SortedDictionary<string, int[]>();
  31. }
  32.  
  33. if (!dragonsData[dragonType].ContainsKey(dragonName))
  34. {
  35. dragonsData[dragonType][dragonName] = new int[3];
  36. }
  37.  
  38. dragonsData[dragonType][dragonName][0] = damage;
  39. dragonsData[dragonType][dragonName][1] = health;
  40. dragonsData[dragonType][dragonName][2] = armor;
  41. }
  42.  
  43. GetResult(dragonsData);
  44. }
  45.  
  46. static void GetResult(Dictionary<string, SortedDictionary<string, int[]>> dragonsData)
  47. {
  48. foreach (var dragonType in dragonsData)
  49. {
  50. Console.WriteLine("{0}::({1:f}/{2:f}/{3:f})",dragonType.Key,dragonType.Value.Select(x=>x.Value[0]).Average(),
  51. dragonType.Value.Select(x => x.Value[1]).Average(), dragonType.Value.Select(x => x.Value[2]).Average());
  52.  
  53. foreach (var dragonNameAndStats in dragonType.Value)
  54. {
  55. Console.WriteLine(@"-{0} -> damage: {1}, health: {2}, armor: {3}",dragonNameAndStats.Key,dragonNameAndStats.Value[0],
  56. dragonNameAndStats.Value[1], dragonNameAndStats.Value[2]);
  57. }
  58. }
  59. }
  60. }
  61. }
Runtime error #stdin #stdout #stderr 0s 138176KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Unhandled Exception:
System.ArgumentNullException: Value cannot be null.
Parameter name: String
  at System.Number.StringToNumber (System.String str, System.Globalization.NumberStyles options, System.Number+NumberBuffer& number, System.Globalization.NumberFormatInfo info, System.Boolean parseDecimal) [0x00006] in <8f2c484307284b51944a1a13a14c0266>:0 
  at System.Number.ParseInt32 (System.String s, System.Globalization.NumberStyles style, System.Globalization.NumberFormatInfo info) [0x00014] in <8f2c484307284b51944a1a13a14c0266>:0 
  at System.Int32.Parse (System.String s) [0x00007] in <8f2c484307284b51944a1a13a14c0266>:0 
  at _11.Dragon_Army.Program.Main () [0x00005] in <cc57ae365e9941119eb41da26458e5b5>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentNullException: Value cannot be null.
Parameter name: String
  at System.Number.StringToNumber (System.String str, System.Globalization.NumberStyles options, System.Number+NumberBuffer& number, System.Globalization.NumberFormatInfo info, System.Boolean parseDecimal) [0x00006] in <8f2c484307284b51944a1a13a14c0266>:0 
  at System.Number.ParseInt32 (System.String s, System.Globalization.NumberStyles style, System.Globalization.NumberFormatInfo info) [0x00014] in <8f2c484307284b51944a1a13a14c0266>:0 
  at System.Int32.Parse (System.String s) [0x00007] in <8f2c484307284b51944a1a13a14c0266>:0 
  at _11.Dragon_Army.Program.Main () [0x00005] in <cc57ae365e9941119eb41da26458e5b5>:0