fork(1) download
  1. using System;
  2.  
  3. public class Test
  4. {
  5. public static void Main()
  6. {
  7. int numberOfTest = 0;
  8. int numberOfContestants = 0;
  9. string[] inputData;
  10. int[] resultsData;
  11. int actualTableIndex = 0;
  12.  
  13. numberOfTest = int.Parse(Console.ReadLine());
  14. for (int i = 0; i < numberOfTest; i++)
  15. {
  16. // Prepare input data.
  17. numberOfContestants = int.Parse(Console.ReadLine().Trim());
  18. inputData = Console.ReadLine().Trim().Split(' ');
  19. resultsData = new int[numberOfContestants];
  20. for (int j = 0; j < numberOfContestants; j++)
  21. {
  22. resultsData[j] = int.Parse(inputData[j]);
  23. }
  24. Array.Sort(resultsData);
  25. // Output max values.
  26. Console.Write(resultsData[numberOfContestants - 1] + " ");
  27. actualTableIndex = numberOfContestants - 2;
  28. while (resultsData[numberOfContestants - 1] == resultsData[actualTableIndex])
  29. {
  30. Console.Write(resultsData[actualTableIndex] + " ");
  31. actualTableIndex--;
  32. if (actualTableIndex < 0)
  33. {
  34. break;
  35. }
  36. }
  37. // Output all other values sorted.
  38. for (int j = 0; j < actualTableIndex + 1; j++)
  39. {
  40. Console.Write(resultsData[j] + " ");
  41. }
  42. Console.WriteLine();
  43. }
  44. }
  45. }
Success #stdin #stdout 0.01s 131648KB
stdin
10
5
1 2 3 4 5  
5
4 5 2 3 5  
2
1 1
3
1 11 111
3 
2 22 222
4 
5 0 0 998
10
999 1000 997 998 0 996 1 999 1000 0
6
1 2 1 2 1 2 
3
0 1 2
4
6 6 6 6
stdout
5 1 2 3 4 
5 5 2 3 4 
1 1 
111 1 11 
222 2 22 
998 0 0 5 
1000 1000 0 0 1 996 997 998 999 999 
2 2 2 1 1 1 
2 0 1 
6 6 6 6