Using the definitions
typedef vector<int> VI;
typedef vector<VI> VVI;
implement a function
int k_esim(int k, const VVI& V);
to return the -th global element (starting at one) of the elements in the vector of vectors @V@. Let @V.size()@. For every , @V[i]@ is sorted increasingly. Furthermore, there are no repeated elements in @V@.
For exemple, if , , and the three vectors are
V[0]
| 1 | 2 | 10 | 15 |
|---|
V[1]
| -5 | -3 | 12 |
|---|
V[2]
| 0 | 3 | 4 | 6 | 20 |
|---|
then the answer is 2, which is the fifth smallest element inside all the vectors.
Let @V[i].size()@. Assume that is between 1 and , that is between 2 and 500, and that some @V[i]@ can be empty. If needed, you can implement auxiliar procedures. Take into account that, for the “large” test cases, and . The expected solution in this cas has cost .
You only need to submit the required procedure; your main program will be ignored.