#C8838. File List Operations
File List Operations
File List Operations
This problem involves managing a file list with several operations. You are required to implement a simple file management system supporting the following operations:
ADD file_name file_size creation_time
: Add a file with the given name, size (in bytes), and creation timestamp. Note that thecreation_time
is provided in the format \(YYYY-MM-DD HH:MM\).DELETE file_name
: Delete all files with the specified name from the file list.LARGEST
: Output the name of the file with the largest size. In case of a tie, the file that appears first in the list is chosen.LATEST
: Output the name of the file with the most recent creation time. The time string comparison is based on the lexicographical order of the timestamp in the format \(YYYY-MM-DD HH:MM\).
If a query operation (LARGEST
or LATEST
) is issued when there are no files in the list, output NULL
.
inputFormat
The input begins with a positive integer Q representing the number of operations. Each of the following Q lines contains one of the following commands:
• ADD file_name file_size creation_time
• DELETE file_name
• LARGEST
• LATEST
When using the ADD command, the creation_time consists of two parts (date and time) separated by a space. For example: "ADD file1.txt 100 2023-01-01 08:00".
outputFormat
For each query operation (LARGEST
or LATEST
), print the corresponding file name on a separate line. If there are no files available for the query, output NULL.## sample
4
ADD file1.txt 100 2023-01-01 08:00
ADD file2.txt 200 2023-01-02 12:00
LARGEST
LATEST
file2.txt
file2.txt
</p>