给出了一个最初具有一些Max.val值的数组,然后有一些查询在Range L,R中进行更新,这样任何位置的值都是最小的.例如:
Update Range 1 3 with value 3
Array 3 3 3 Max.val Max.val
Now update 2 and 4 with 1
Array 3 1 1 1 Max.val
Now update 1 and 2 with 2
Array 2 1 1 1 Max.val
i.e update only if(A[i]>value) A[i]=value;
Run Code Online (Sandbox Code Playgroud)
在上面的查询之后我必须显示我的最终结果 array:i.e 2 1 1 1 Max.val
我正在使用Segment Tree来解决这个问题,但我得到了TLE(超出时间限制).我不知道为什么?我的方法是logN. 这是我的更新功能
public static void lets_change(int curr, int[] T, int x, int y, int a, int b, int c) {
// …Run Code Online (Sandbox Code Playgroud)