#K33932. Categorize Files by Size
Categorize Files by Size
Categorize Files by Size
You are given a list of files, each represented by a filename and its size in bytes. Your task is to separate these files into two categories:
- Small files: Files of size at most 1000 bytes.
- Large files: Files of size greater than 1000 bytes.
The input is provided via standard input, and the results should be printed to standard output. The first line of input contains an integer N representing the total number of files. This is followed by N lines, each containing a filename and its size (separated by a space).
The output should consist of two lines. The first line lists, in the order given, the filenames corresponding to small files (size ≤ 1000 bytes). The second line lists the filenames corresponding to large files (size > 1000 bytes). If there are no files in one category, output an empty line for that category.
Note: If a file has a size exactly 1000 bytes, it is categorized as a small file.
inputFormat
The first line contains an integer N (1 ≤ N ≤ 10^5) denoting the number of files. Each of the next N lines contains a string (the filename) and an integer (the file size in bytes), separated by a single space. Filenames do not have spaces.
outputFormat
Print two lines:
- The first line contains the filenames of files with sizes ≤ 1000 bytes separated by a single space. If there are no such files, print an empty line.
- The second line contains the filenames of files with sizes > 1000 bytes separated by a single space. If there are no such files, print an empty line.## sample
3
file1.txt 500
file2.txt 1500
file3.txt 1000
file1.txt file3.txt
file2.txt
</p>