#C4162. Load Shedding Manager Simulation

    ID: 47670 Type: Default 1000ms 256MiB

Load Shedding Manager Simulation

Load Shedding Manager Simulation

This problem simulates a load shedding management system for an energy company. The system maintains a list of areas and their electricity consumption in kilowatt-hours (kWh). You are required to implement three operations:

  • ADD areaName: Adds a new area with an initial consumption of 0. If the area already exists, do nothing.
  • REPORT areaName consumption: If the area exists, increases its consumption by the given amount. If it does not exist, ignore the operation.
  • SCHEDULE threshold: Filters out the areas that have a total consumption strictly greater than the threshold. The qualifying areas should be printed in descending order of their consumption. If no area qualifies, output None.

The input is given as multiple commands and you should process them sequentially. For every SCHEDULE command, output the result on a new line.

Note: All operations and outputs are via stdin and stdout.

inputFormat

The first line contains an integer Q, denoting the number of operations. Each of the next Q lines contains a command in one of the following forms:

  1. ADD areaName
  2. REPORT areaName consumption
  3. SCHEDULE threshold

For the SCHEDULE command, you must output a line containing the space-separated area names whose consumption is strictly greater than the specified threshold, sorted in descending order of consumption. If no area qualifies, output 'None'.

outputFormat

For every SCHEDULE command in the input, output a single line. The line should contain the space-separated area names (sorted in descending order of consumption) that meet the criteria. If no area qualifies, output 'None'.## sample

5
ADD Area1
REPORT Area1 350
ADD Area2
REPORT Area2 250
SCHEDULE 300
Area1