viraco4a

04.Balls

Mar 12th, 2018
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace Balls
  6. {
  7. class Program
  8. {
  9. static void Main()
  10. {
  11. var colors = new Dictionary<string, int>()
  12. {
  13. { "red", 5 }, { "orange", 10 },{ "yellow", 15 },{ "white", 20 }
  14. };
  15. var points = new Dictionary<string, int>()
  16. {
  17. { "red", 0 }, { "orange", 0 },{ "yellow", 0 },{ "white", 0 }
  18. };
  19. int N = int.Parse(Console.ReadLine());
  20. int others = 0;
  21. int totalPoints = 0;
  22. int black = 0;
  23. for (int i = 0; i < N; i++)
  24. {
  25. string input = Console.ReadLine().ToLower();
  26. if (input == "black")
  27. {
  28. totalPoints /= 2;
  29. black++;
  30. }
  31. else if (!colors.ContainsKey(input))
  32. {
  33. others++;
  34. }
  35. else
  36. {
  37. points[input]++;
  38. totalPoints += colors[input];
  39. }
  40. }
  41.  
  42. Console.WriteLine($"Total points: {totalPoints}");
  43. Console.WriteLine($"Points from red balls: {points["red"]}");
  44. Console.WriteLine($"Points from orange balls: {points["orange"]}");
  45. Console.WriteLine($"Points from yellow balls: {points["yellow"]}");
  46. Console.WriteLine($"Points from white balls: {points["white"]}");
  47. Console.WriteLine($"Other colors picked: {others}");
  48. Console.WriteLine($"Divides from black balls: {black}");
  49.  
  50. }
  51. }
  52. }
Add Comment
Please, Sign In to add comment