VPanev

Untitled

Nov 18th, 2021
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.44 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4.  
  5. namespace ConsoleApp1
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. int trophiesNumber = int.Parse(Console.ReadLine());
  12. int[] trophiesRank = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
  13. Array.Sort(trophiesRank);
  14.  
  15. int maxRank = trophiesRank.Max();
  16.  
  17. List<int> firstShelf = new List<int>();
  18. List<int> secondShelf = new List<int>();
  19. List<int> thirdShelf = new List<int>();
  20. List<int> forthShelf = new List<int>();
  21.  
  22.  
  23.  
  24. for (int i = 0; i <trophiesRank.Length; i++)
  25. {
  26. if (trophiesRank[i] > 0.9 * maxRank)
  27. {
  28. firstShelf.Add(trophiesRank[i]);
  29. }
  30. else if (trophiesRank[i] > 0.5 * maxRank && trophiesRank[i] <= 0.9 * maxRank)
  31. {
  32. secondShelf.Add(trophiesRank[i]);
  33. }
  34. else if (trophiesRank[i] > 0.2 * maxRank && trophiesRank[i] <= 0.5 * maxRank)
  35. {
  36. thirdShelf.Add(trophiesRank[i]);
  37. }
  38. else if (trophiesRank[i] <= 0.2 * maxRank)
  39. {
  40. forthShelf.Add(trophiesRank[i]);
  41. }
  42. }
  43.  
  44. firstShelf.Reverse();
  45. secondShelf.Reverse();
  46. thirdShelf.Reverse();
  47. forthShelf.Reverse();
  48.  
  49. if (firstShelf.Count != 0)
  50. {
  51. Console.WriteLine(string.Join(" ", firstShelf));
  52. }
  53. else
  54. {
  55. Console.WriteLine("empty");
  56. }
  57. if (secondShelf.Count != 0)
  58. {
  59. Console.WriteLine(string.Join(" ", secondShelf));
  60. }
  61. else
  62. {
  63. Console.WriteLine("empty");
  64. }
  65. if (thirdShelf.Count != 0)
  66. {
  67. Console.WriteLine(string.Join(" ", thirdShelf));
  68. }
  69. else
  70. {
  71. Console.WriteLine("empty");
  72. }
  73. if (forthShelf.Count != 0)
  74. {
  75. Console.WriteLine(string.Join(" ", forthShelf));
  76. }
  77. else
  78. {
  79. Console.WriteLine("empty");
  80. }
  81. }
  82. }
  83. }
  84.  
  85.  
Advertisement
Add Comment
Please, Sign In to add comment