median + prefix sum of set bit's indices
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    long long minimumMoves(vector<int>& nums, int k, int mC) {\n        vector<long long> preSum({0});\n        int n=nums.size();\n        for(int i=0;i<n;i++){\n            if(nums[i]){\n                preSum.push_back(preSum.back()+i+1);\n            }\n        }   \n        int m=max(0,k-mC);\n        long long ans=1e14;\n        n=preSum.size();\n        for(int l=m;l<=min(n-1,m+3);l++){\n            if(l==0){\n                ans=min(ans,(long long)max(0,2*(k-l)));\n                continue;\n            }\n            int mid1=l-l/2;\n            int mid2=l/2+1;\n            for(int i=0;i<n-l;i++){\n                long long res=-(preSum[i+mid1]-preSum[i]) + (preSum[i+l]-preSum[i+mid2-1]);\n                res=max(0LL,res);\n                ans=min(ans,res+max(0,2*(k-l)));\n            }\n        }\n        return ans;\n    }\n};\n```
['C++']