I came up with this problem recently but haven't been able to find an efficient approach. Since it's a self-created problem, I don't have official test cases.
Problem Statement
There is a sequence a of n integers. Process q queries given in order. For q-th query, you are given integers l, r (1 <= l <= r <= n) and a integer x.Perform the following in order: Add x for each of a[l], a[l + 1],.., a[r]. Let m = r - l + 1, and b = (b[1], b[2],.., b[m]) = (a[l], a[l + 1],.., a[r]) and sort(b + 1, b + m + 1). Present the results of ((m - 1) * b[1] + (m - 1) * b[2] + .. + b[m]) % MOD (MOD = 1e9 + 7) (n <= 1e5, q <= 1e5, |a[i]| <= 1e9)
I can't think of a specific time limit for this problem either, but can you find the quickest way to solve it?
Update : The addition of x to the values from position l to r in the i-th query will apply to all queries from i + 1 onwards, meaning that after query i, array a becomes a = (a[1], a[2], ..., a[l] + x, a[l + 1] + x, a[r] + x, ..., a[n])




