Write an efficient function
| C++ | |
| Python | |
that returns the @k@-th largest of all the elements contained in @v1@ and @v2@, taking into account repeated elements. For instance, if @v1@ contains a 5 and a 7, and @v2@ only contains a 5, then a call to @select(1, v1, v2)@ should return 5, a call to @select(2, v1, v2)@ should also return 5, and a call to @select(3, v1, v2)@ should return 7.
The vectors @v1@ and @v2@ are sorted in nondecreasing order. The index is correct, that is, it is between 1 and @v1.size()@ @v2.size()@. Therefore, at least one of the vectors is not empty.
You only need to submit the required procedure; your main program will be ignored.