#C3953. Task Manager System
Task Manager System
Task Manager System
This problem requires you to implement a Task Manager system that supports three commands:
add <description> <priority>
: Add a new task with the specified description and priority.complete <description>
: Mark the task with the given description as completed (and remove it).list
: List all pending tasks sorted by descending priority. In the case where two tasks have the same priority, they should be sorted in lexicographically increasing order of their description.
The commands are provided via standard input. For each list
command, the program should output each matching task on a new line in the format description priority
.
In mathematical notation, if \( T \) is the set of active tasks where each task \( t \) is represented as \( (d_t, p_t) \), then the tasks are printed in order satisfying: \[ p_i > p_j \quad \text{or}\quad (p_i = p_j \text{ and } d_i < d_j). \]
inputFormat
The first line contains an integer \(N\) which denotes the number of commands. Each of the following \(N\) lines contains a command. The commands can be of three types:
add <description> <priority>
complete <description>
list
Input is read from standard input (stdin).
outputFormat
For every list
command encountered in the input, output the current tasks. Each task should be printed on a separate line in the format description priority
, according to the sorting order defined in the problem statement. The output is printed to standard output (stdout).
7
add Task1 5
add Task2 10
list
complete Task1
list
add Task3 1
list
Task2 10
Task1 5
Task2 10
Task2 10
Task3 1
</p>