#C8801. Town Water Source Simulation

    ID: 52824 Type: Default 1000ms 256MiB

Town Water Source Simulation

Town Water Source Simulation

You are given information about a town's water sources and a series of operations to simulate water utilization and refill. Each water source has a capacity and a current water level. The operations include using water, adding water, and querying whether a water source has at least a specified amount of water.

For each water source, the water level is updated according to the following formulas:

When adding water: \[ \text{current\_level} = \min(\text{capacity},\; \text{current\_level} + \text{amount}) \]

When utilizing water: \[ \text{current\_level} = \max(0,\; \text{current\_level} - \text{amount}) \]

For a query, if the current water level is at least the queried amount, the answer is "YES"; otherwise, it is "NO".

Your task is to simulate these operations and output the result of each query operation.

inputFormat

The first line of input contains two integers n and q where n is the number of water sources and q is the number of operations.

The next n lines each contain three integers: the type of the water source (an integer which is not used in the operations), its capacity, and its current water level.

The following q lines describe an operation in one of three formats (each operation is given on a separate line with three integers):

  • 1 x amount: Utilize water from source x by the given amount.
  • 2 x amount: Add water to source x by the given amount.
  • 3 x amount: Query if source x has at least amount water.

Note: Sources are 1-indexed.

outputFormat

For each query operation (operation type 3), output either "YES" or "NO" (each on a new line) based on the water level after processing previous operations.

## sample
3 5
1 100 50
2 200 150
1 300 75
1 1 20
2 2 25
3 3 100
1 3 50
3 3 20
NO

YES

</p>