C++ solution to the kth largest element problem