My solution (which is the partitioning solution described in https://discuss.leetcode.com/topic/15256/4-c-solutions-using-partition-max-heap-priority_queue-and-multiset-respectively) fails on test case:
But I think there might be a problem with a test case? When I print the input it shows just  and not [2,1]. I get a "fatal error: Index out of range", but the message seems to be raised inside the code that checks the results after my function has already returned a value.
I rewrote the solution in C++ and it worked.