Rust idiomatic solution | binary heap
\nuse std::collections::BinaryHeap;\nuse std::cmp::Reverse;\nimpl Solution {\n    pub fn k_sum(mut nums: Vec<i32>, mut k: i32) -> i64 {\n        let mut sum = n
```\nuse std::collections::BinaryHeap;\nuse std::cmp::Reverse;\nimpl Solution {\n    pub fn k_sum(mut nums: Vec<i32>, mut k: i32) -> i64 {\n        let mut sum = nums.iter().filter(|&&v| v > 0).map(|&v| v as i64).sum::<i64>();\n        let mut nums: Vec<_> = nums.into_iter().map(|v| v.abs()).collect();\n        nums.sort_unstable();\n        \n        let mut curr = 0;\n        let mut min_heap = BinaryHeap::new();\n        min_heap.push(Reverse((nums[0] as i64, 0)));\n        k -= 1;\n        while !min_heap.is_empty() && k > 0 {\n            let Reverse((val, idx)) = min_heap.pop().unwrap();\n            curr = val;\n            if idx + 1 < nums.len() {\n                min_heap.push(Reverse((val + nums[idx + 1] as i64, idx + 1)));\n                min_heap.push(Reverse((val - nums[idx] as i64 + nums[idx + 1] as i64, idx + 1)));\n            }\n            k -= 1;\n        }\n        sum - curr\n    }\n}\n```
['Rust']