#C4211. Find the Median File Index
Find the Median File Index
Find the Median File Index
You are given T files, each containing a list of integer measurements. All the measurement values from all files are combined and sorted in non-decreasing order. The median is defined as the lower middle element (i.e. the element at index \(\lfloor N/2 \rfloor\) when there are \(N\) total elements, with 0-indexing).
Your task is to determine the smallest file index (1-indexed) that contains the median value.
Note: Each file's numbers are provided as a space-separated list in the input. The order of values in each file is arbitrary. You must combine all values, sort them, find the median, and then locate the file having the median value (if the median appears in multiple files, output the one with the smallest index).
inputFormat
The input is given via standard input as follows:
The first line contains an integer (T) representing the number of files.
Each of the next (T) lines begins with an integer (n) (the number of measurements in that file) followed by (n) space-separated integers representing the measurements.
outputFormat
Output a single integer to standard output, which is the 1-indexed file number that contains the median measurement.## sample
3
4 1 3 5 7
3 2 6 8
5 -1 0 4 9 10
1
</p>