CF1696G.Fishingprince Plays With Array Again
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Suppose you are given a 1-indexed sequence a of non-negative integers, whose length is n , and two integers x , y . In consecutive t seconds ( t can be any positive real number), you can do one of the following operations:
- Select 1≤i<n , decrease ai by x⋅t , and decrease ai+1 by y⋅t .
- Select 1≤i<n , decrease ai by y⋅t , and decrease ai+1 by x⋅t .
Define the minimum amount of time (it might be a real number) required to make all elements in the sequence less than or equal to 0 as f(a) .
For example, when x=1 , y=2 , it takes 3 seconds to deal with the array [3,1,1,3] . We can:
- In the first 1.5 seconds do the second operation with i=1 .
- In the next 1.5 seconds do the first operation with i=3 .
We can prove that it's not possible to make all elements less than or equal to 0 in less than 3 seconds, so f([3,1,1,3])=3 .
Now you are given a 1-indexed sequence b of positive integers, whose length is n . You are also given positive integers x , y . Process q queries of the following two types:
- 1 k v: change bk to v .
- 2 l r: print f([bl,bl+1,…,br]) .
输入格式
The first line of input contains two integers n and q ( 2≤n≤2⋅105 , 1≤q≤2⋅105 ).
The second line of input contains two integers x and y ( 1≤x,y≤106 ).
The third line of input contains n integers b1,b2,…,bn ( 1≤bi≤106 ).
This is followed by q lines. Each of these q lines contains three integers. The first integer op is either 1 or 2 .
- If it is 1 , it is followed by two integers k , v ( 1≤k≤n , 1≤v≤106 ). It means that you should change bk to v .
- If it is 2 , it is followed by two integers l , r ( 1≤l<r≤n ). It means that you should print f([bl,bl+1,…,br]) .
输出格式
For each query of type 2 , print one real number — the answer to the query. Your answer is considered correct if its absolute error or relative error does not exceed 10−9 .
输入输出样例
输入#1
4 3 1 2 3 1 1 4 2 1 4 1 1 1 2 1 3
输出#1
3.500000000000000 1.000000000000000
说明/提示
Let's analyse the sample.
In the first query, we are asked to compute f([3,1,1,4]) . The answer is 3.5 . One optimal sequence of operations is:
- In the first 1.5 seconds do the second operation with i=1 .
- In the next 2 seconds do the first operation with i=3 .
In the third query, we are asked to compute f([1,1,1]) . The answer is 1 . One optimal sequence of operations is:
- In the first 0.5 seconds do the second operation with i=1 .
- In the next 0.5 seconds do the first operation with i=2 .