100% || C++
Intuitionfor a query q, there are some elements smaller than q denoted as leftsum rest are called rightsum. Find teh sum of both of the valuesApproachComplexity
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
for a query `q`, there are some elements smaller than `q` denoted as `leftsum` rest are called `rightsum`. Find teh sum of both of the values

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```cpp []
class Solution {
public:
    vector<long long> minOperations(vector<int>& nums, vector<int>& queries) {
        int n=nums.size();
        vector <long long int> ans;
        sort(nums.begin(),nums.end());

        vector <long long int> prefix(nums.size(),0);
        prefix[0]=nums[0];
        for(int i=1;i<nums.size();i++){
            prefix[i] = prefix[i-1] + nums[i];
        }

        for(auto &q:queries){
            long long greater=lower_bound(nums.begin(),nums.end(),q)-nums.begin();


            long long leftSum=(greater>0)?(q*1LL*greater-prefix[greater-1]):0;
            long long rightSum=(greater<n)?((prefix[n-1]-(greater>0?prefix[greater-1]:0))-q*1LL*(n-greater)):0;

            ans.push_back(leftSum+rightSum);
        }
        return ans;
    }
};
```
['C++']