Easy C++
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    #define ll long long int\n    vector<long long> minOperations(vector<int>& a, vector<int>& q) {\n        sort(a.begin(),a.end());\n        int n=a.size();\n        ll pre[n],suf[n];\n        pre[0]=a[0],suf[n-1]=a[n-1];\n        for(int i=1;i<n;i++)pre[i]=pre[i-1]+a[i];\n        for(int i=n-2;i>=0;i--)suf[i]=suf[i+1]+a[i];\n        vector<ll> ans;\n        for(int i=0;i<q.size();i++)\n        {\n            ll no=q[i];\n            ll s=upper_bound(a.begin(),a.end(),no)-a.begin();\n            if(s==0)ans.push_back(suf[s]-(n-s)*no);\n            else if(s==n)ans.push_back(no*s-pre[s-1]);\n            else ans.push_back(no*s-pre[s-1]+suf[s]-(n-s)*no);\n        }\n        return ans;\n    }\n};\n```
['C++']