using System; using System.Collections.Generic; using System.IO; using System.Linq; class Solution { static void Main(String[] args) { int q = Convert.ToInt32(Console.ReadLine()); for (int a0 = 0; a0 < q; a0++) { string[] tokens_len = Console.ReadLine().Split(' '); int len = Convert.ToInt32(tokens_len[0]); int c = Convert.ToInt32(tokens_len[1]); // your code goes here //int[] nums = { 1, 2, 3, 4, 5 }; //int[] nums = { 4, 2, 1, 3, 5 }; int[] nums = new int[len]; for (int i = 0; i < nums.Length; i++) { nums[i] = i + 1; } count = c; int[] nums1 = lena_sort(nums); Console.WriteLine(); Console.ReadLine(); } } public static int count = 0; public static int[] lena_sort(int[] nums) { if (nums.Length == 0) return nums; int pivot = nums[nums.Length - 1]; List array_less = new List(); List array_more = new List(); List sorted_less = new List(); List sorted_more = new List(); List ans = new List(); for (int i = nums.Length - 2; i >= 0; --i) { // Comparison if (nums[i] > pivot) { count--; array_less.Add(nums[i]); } else { count--; array_more.Add(nums[i]); } } sorted_less = lena_sort(array_less.ToArray()).ToList(); sorted_more = lena_sort(array_more.ToArray()).ToList(); foreach (var v in sorted_less) { ans.Add(v); } ans.Add(pivot); foreach (var v in sorted_more) { ans.Add(v); } return ans.ToArray(); } }