#C2056. Large File Finder
Large File Finder
Large File Finder
Given multiple directories each containing a list of files with their corresponding sizes in megabytes (MB), your task is to find and list the names of files whose sizes are strictly greater than a given threshold T. The output should be sorted primarily in descending order of file sizes and secondarily in lexicographical order if sizes are equal.
The problem can be formulated mathematically as follows. Let \(F = \{(f_i, s_i)\}\) be the set of all files where \(s_i > T\). You are required to sort \(F\) by \(s_i\) in descending order and then by \(f_i\) in ascending order when \(s_i\) values are equal.
This is a straightforward problem that tests your ability to parse input, filter based on a condition, and sort according to multiple criteria.
inputFormat
The input is given from stdin and has the following format:
n T path_1 m_1 filename_1 size_1 filename_2 size_2 ... path_2 m_2 filename_1 size_1 ... ...
Where:
- n is an integer representing the number of directories.
- T is a float representing the size threshold in MB.
- For each directory, the first line is the directory path (a string).
- The next line contains an integer m indicating the number of files in that directory.
- Then follow m lines each containing a filename (a string without spaces) and its size (a float), separated by a space.
outputFormat
Output to stdout the names of the files that have a size strictly greater than T. Each filename should be printed on a separate line, in the order determined by the sorting criteria: first by size in descending order, then by lexicographical order of the filename in case of ties.
## sample2 100.0
/root/documents
3
report.txt 120.5
thesis.pdf 300.2
notes.docx 50.0
/root/photos
2
vacation.jpg 200.0
project.png 150.0
thesis.pdf
vacation.jpg
project.png
report.txt
</p>