#P4585. [FJOI2015] 火星商店问题
[FJOI2015] 火星商店问题
Description
On a commercial street on Mars, there are shops arranged in order by shop IDs . Among the many goods sold in the shops, each item is priced with a non-negative integer . Each shop may bring in some new goods every day, and the price may be the same as existing goods.
When Martians shop on this street, they usually visit all shops along a certain segment of the street, for example, the shops with IDs in the interval , and choose their favorite item from them. Each Martian has different preferences.
Usually, each Martian has a personal preference code . For an item priced at , a Martian with preference code likes it in proportion to the value of . That is, the larger is, the more they like the item.
Each Martian’s shopping card can only be used to buy goods stocked within the most recent days (including the current day) across all shops. In addition, each shop has one special item that is not restricted by the stocking date, and each Martian can choose this special item at any time. The supply of every item in each shop is guaranteed; there is no out-of-stock issue.
Given events arranged in chronological order, for each shopping Martian, compute the item they like most in this shopping activity, i.e., output the maximum value of . The events in chronological order refer to the following two types:
0 s v, meaning that shop stocks a new item priced at on the current day.
1 l r x d, meaning that a Martian shops on the current day in shops with IDs in , buying items stocked within days, and this Martian’s preference code is .
Input Format
The first line contains two positive integers , representing the total number of shops and the total number of events.
The second line contains integers; the -th integer is the price of the special item in shop .
The next lines each describe one event. The events of each day are arranged in the order that event type comes first, then event type .
Output Format
For each event of type , output one line with one integer representing the answer.
4 6
1 2 3 4
1 1 4 1 0
0 1 4
0 1 3
1 1 1 1 0
1 1 1 1 1
1 1 2 1 2
5
0
2
5
Hint
Constraints
For of the data, all input integers are in the range .
Translated by ChatGPT 5
京公网安备 11011102002149号