Maskpunk 2077
Time limit1sMemory limit1024 MB
Houses sit on a line with mask costs and edge travel times; handle point updates to travel times and queries for the cheapest mask reachable from a house within m minutes.
- Level
Hard8 of 10
- Topics
- Segment tree, Binary search, Prefix sum, Array
- Solved
- No attempts yet
Problem
The year is 2077, and the spread of an unending pandemic means every household can make masks at home. Skill varies from person to person, though, so the cost of producing a mask differs from house to house.
In Seogang Village, where houses sit in order along a straight line, the household in the -th house needs to make a mask, and moving between the -th and -th houses takes minutes.
The villagers of Seogang call in to ask what the cheapest mask they can get within minutes costs. Juhyeon, who handles phone duties at the city hall, is having a hard time dealing with these calls, because the ever-changing traffic conditions mean the travel times have to be recalculated on the spot.
Juhyeon has asked you to write a program that computes the answers to the villagers' calls. You do not know how to refuse, so you have no choice but to take the request.
Input
The first line gives , the number of houses in Seogang Village. ()
The second line gives the mask production costs , , , of each household, separated by spaces. ()
The third line gives the initial travel times , , , , separated by spaces. ()
The fourth line gives , the number of tasks Juhyeon must handle. ()
Each of the next lines gives one task, in order, and each is one of the following two types.
UPDATE: set the travel time between the -th and -th houses to minutes. (, )CALL: print the price of the cheapest mask the -th house can obtain within minutes. (, )
Output
Print the results of the CALL tasks, one per line.