atcoder#ABC287G. [ABC287G] Balance Update Query
[ABC287G] Balance Update Query
Score : points
Problem Statement
Takahashi has cards of each of kinds. Initially, the score and quota of the -th kind of card are set to and , respectively.
Given queries in the following formats, process them in order.
1 x y
: set the score of the -th kind of card to .2 x y
: set the quota of the -th kind of card to .3 x
: if one can choose cards subject to the following condition, print the maximum possible sum of the scores of the chosen cards; print-1
otherwise.- The number of chosen cards of each kind does not exceed its quota.- The number of chosen cards of each kind does not exceed its quota.
Constraints
- For each query of the -st kind, and .
- For each query of the -nd kind, and .
- For each query of the -rd kind, .
- There is at least one query of the -rd kind.
- All values in the input are integers.
Input
The input is given from Standard Input in the following format, where denotes the -th query:
Output
Print lines, where is the number of queries of the -rd kind. The -th line should contain the response to the -th such query.
3
1 1
2 2
3 3
7
3 4
1 1 10
3 4
2 1 0
2 3 0
3 4
3 2
11
19
-1
4
For the first query of the -rd kind, you can choose one card of the -nd kind and three cards of the -rd kind for a total score of , which is the maximum.
For the second such query, you can choose one card of the -st kind and three cards of the -rd kind for a total score of , which is the maximum.
For the third such query, you cannot choose four cards, so -1
should be printed.
For the fourth such query, you can choose two cards of the -nd kind for a total score of , which is the maximum.