CF627B.Factory Repairs

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

A factory produces thimbles in bulk. Typically, it can produce up to aa thimbles a day. However, some of the machinery is defective, so it can currently only produce bb thimbles each day. The factory intends to choose a kk -day period to do maintenance and construction; it cannot produce any thimbles during this time, but will be restored to its full production of aa thimbles per day after the kk days are complete.

Initially, no orders are pending. The factory receives updates of the form did_{i} , aia_{i} , indicating that aia_{i} new orders have been placed for the did_{i} -th day. Each order requires a single thimble to be produced on precisely the specified day. The factory may opt to fill as many or as few of the orders in a single batch as it likes.

As orders come in, the factory owner would like to know the maximum number of orders he will be able to fill if he starts repairs on a given day pip_{i} . Help the owner answer his questions.

输入格式

The first line contains five integers nn , kk , aa , bb , and qq ( 1<=k<=n<=2000001<=k<=n<=200000 , 1<=b<a<=10\ 000 , 1<=q<=2000001<=q<=200000 ) — the number of days, the length of the repair time, the production rates of the factory, and the number of updates, respectively.

The next qq lines contain the descriptions of the queries. Each query is of one of the following two forms:

  • 1 di ai1\ d_{i}\ a_{i} ( 1<=di<=n1<=d_{i}<=n , 1<=ai<=10 0001<=a_{i}<=10\ 000 ), representing an update of aia_{i} orders on day did_{i} , or
  • 2 pi2\ p_{i} ( 1<=pi<=nk+11<=p_{i}<=n-k+1 ), representing a question: at the moment, how many orders could be filled if the factory decided to commence repairs on day pip_{i} ?

It's guaranteed that the input will contain at least one query of the second type.

输出格式

For each query of the second type, print a line containing a single integer — the maximum number of orders that the factory can fill over all nn days.

输入输出样例

  • 输入#1

    5 2 2 1 8
    1 1 2
    1 5 3
    1 2 1
    2 2
    1 4 2
    1 3 2
    2 1
    2 3
    

    输出#1

    3
    6
    4
    
  • 输入#2

    5 4 10 1 6
    1 1 5
    1 5 5
    1 3 2
    1 5 2
    2 1
    2 2
    

    输出#2

    7
    1
    

说明/提示

Consider the first sample.

We produce up to 11 thimble a day currently and will produce up to 22 thimbles a day after repairs. Repairs take 22 days.

For the first question, we are able to fill 11 order on day 11 , no orders on days 22 and 33 since we are repairing, no orders on day 44 since no thimbles have been ordered for that day, and 22 orders for day 55 since we are limited to our production capacity, for a total of 33 orders filled.

For the third question, we are able to fill 11 order on day 11 , 11 order on day 22 , and 22 orders on day 55 , for a total of 44 orders.

首页