题目:
问你subarray的和sort之后
left到right加起来是多少
思路:
照做
把subarray 通通弄出来之后
sort加起来
姆咪
```cpp
class Solution {
public:
int rangeSum(vector<int>& nums, int n, int left, int right)
{
vector<int> sum(n,0);
vector<int> paper(n * (n + 1) / 2 , 0);
sum[0] = nums[0];
for(int i = 1 ; i < n ; i ++)
{
sum[i]+=sum[i-1];
sum[i]+=nums[i];
}
int p = 0;
for(int i = 0 ; i < n ; i ++)
{
paper[p] = sum[i];
p++;
for(int j = i+1 ; j < n ; j ++)
{
paper[p] = sum[j] - sum[i];
p++;
}
}
sort(paper.begin() , paper.end());
int res = 0;
for(int i = left -1 ; i < right ; i ++)
{
res += paper[i];
res %= 1000000007;
}
return res;
}
};
```