Loading...
Loading...
The exam cell stores mark totals in a table of r rows and c columns. Each row is sorted from left to right, and the first value of each row is larger than the last value of the row above. So reading the rows one after another gives one increasing list.
Print the row and column of the value t, both counting from 0. If t is not in the table, print -1 -1.
-1 -1.Example 1
Input
3 4 23 1 3 5 7 10 11 16 20 23 30 34 60
Output
2 0
23 is the first value of the last row.
Example 2
Input
2 3 13 1 4 7 10 12 15
Output
-1 -1
13 would sit between 12 and 15, but it is not there.
Try the problem first. Open one hint at a time.
Think of the table as one long sorted list of r × c values.
Position p in that long list is row p / c and column p % c.
Search positions 0 to r × c - 1, turning each middle position into a row and a column.
Write your Java code, run it on the examples and submit it to hidden tests.
Solve in the editor