#C4617. Project Manager Operations

    ID: 48175 Type: Default 1000ms 256MiB

Project Manager Operations

Project Manager Operations

Problem Description:

Implement a ProjectManager class to manage projects, each identified by a unique id and associated with an integer priority. The class should support the following operations:

1. ADD: Add a new project with a given id and priority.
2. UPDATE: Update the priority of an existing project.
3. DELETE: Remove an existing project.
4. GET: Retrieve the project with the highest priority. If multiple projects have the same priority, the project that was added first (i.e. the smallest order) should be returned.
5. LIST: List all projects with priorities within a specified range. A project's priority p qualifies if it satisfies $$minP \leq p \leq maxP$$. The output list must be sorted in descending order of priority and, in case of ties, in the order the projects were added (earlier ones come first).

The input consists of a series of commands (one per line), which you must process accordingly. For each GET command, print the result on a new line; for LIST commands, output the list of projects as specified.

inputFormat

The first line contains an integer Q denoting the number of operations. Each of the next Q lines contains an operation in one of the following formats:

• ADD id priority • UPDATE id priority • DELETE id • GET • LIST minP maxP

Notes:

  • 'id' is a string (without spaces).
  • 'priority', 'minP', 'maxP' are integers.
  • For commands that do not require an output (ADD, UPDATE, DELETE), no output is expected.

outputFormat

For each GET command, output a single line containing the project id and its priority separated by a space. If no project exists, output None.
For each LIST command, output a single line listing projects in the format id:priority separated by spaces. If no project qualifies, output an empty line.## sample

5
ADD p1 10
ADD p2 20
GET
LIST 5 15
GET
p2 20

p1:10 p2 20

</p>