#P6013. [CSGRound3] 压岁钱

[CSGRound3] 压岁钱

Background

Wishing everyone a happy Year of the Rat in the Gengzi year! Best wishes!

May the pneumonia outbreak be brought under control as soon as possible. Stay strong, China!

When the New Year comes, Xiao Z can always receive a lot of lucky money.

Xiao Z is a player who really likes spending money in games, so from time to time he will spend part of his lucky money to buy skins and gems.

But Xiao Z is also very worried that he will spend all his lucky money in just a few days. To deal with this, Xiao Z has a sealing technique that can temporarily seal away part of his money (meaning it cannot be spent). It can only be used after the seal is lifted on some day.

Problem Description

There are mm events in total, and the events are divided into the following 33 types.

  1. Xiao Z receives aa yuan of lucky money.
  2. Xiao Z spends aa yuan of lucky money to buy skins.
  3. Xiao Z seals aa yuan of his money. The seal will be lifted 11 second before event bb happens. It is guaranteed that each time, the money Xiao Z currently has is greater than or equal to the amount being sealed.

If Xiao Z does not have enough money to spend on some event, Xiao Z will feel unhappy. At the same time, when he does not have enough money, Xiao Z will not spend the money.

Please tell Xiao Z in how many events he will not have enough money to spend.

Input Format

The first line contains an integer mm, which indicates the total number of events.

The next mm lines each start with an integer tt, indicating the type of the event.

If t=1t=1 or t=2t=2, then it is followed by an integer aa.

If t=3t=3, then it is followed by two integers a,ba,b.

Output Format

Output one line with one integer, indicating the number of events in which there is not enough money to spend.

3
1 10
2 20
2 10
1
5
1 10
3 5 5
2 10
1 10
2 20
1

Hint

[Sample 1 Explanation]

Day 1: Income 1010 yuan, balance 1010 yuan.

Day 2: Not enough to spend 2020 yuan, balance 1010 yuan.

Day 3: Spend 1010 yuan, balance 00 yuan.

Total: 11 day.

[Sample 2 Explanation]

Day 1: Income 1010 yuan, balance 1010 yuan.

Day 2: Seal 55 yuan, balance 55 yuan.

Day 3: Not enough to spend 1010 yuan, balance 55 yuan.

Day 4: Income 1010 yuan, balance 1515 yuan.

Day 5: The seal is lifted, spend 2020 yuan, balance 00 yuan.

Total: 11 day.


[Constraints]

For 50%50\% of the testdata, m,a5×103m,a \leq 5\times 10^3.

For 70%70\% of the testdata, t3t \ne 3.

For 100%100\% of the testdata, 1bm106 1 \leq b \le m \leq 10^6, 1t31 \le t \le 3, 1a1071 \leq a \leq 10^7.

Translated by ChatGPT 5