コード例 #1
0
        public static int[] Solve(int[] heights, int[] front)
        {
            int         n    = heights.Length;
            SegmentTree tree = new SegmentTree();

            int[] result = new int[n];
            for (int i = 0; i < n; i++)
            {
                tree.ChangeCount(heights[i], 1);
            }

            for (int i = n - 1; i >= 0; i--)
            {
                result[i] = tree.GetValue(i - front[i] + 1);
                tree.ChangeCount(result[i], -1);
            }

            return(result);
        }