[Solution] Fishingprince Plays With Array Again Codeforces Solution
Suppose you are given a 1-indexed sequence of non-negative integers, whose length is , and two integers , . In consecutive seconds ( can be any positive real number), you can do one of the following operations:
- Select , decrease by , and decrease by .
- Select , decrease by , and decrease by .
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 as .
For example, when , , it takes seconds to deal with the array . We can:
- In the first seconds do the second operation with .
- In the next seconds do the first operation with .
We can prove that it's not possible to make all elements less than or equal to in less than seconds, so .
Now you are given a 1-indexed sequence of positive integers, whose length is . You are also given positive integers , . Process queries of the following two types:
- 1 k v: change to .
- 2 l r: print .
The first line of input contains two integers and (, ).
The second line of input contains two integers and ().
The third line of input contains integers ().
This is followed by lines. Each of these lines contains three integers. The first integer is either or .
- If it is , it is followed by two integers , (, ). It means that you should change to .
- If it is , it is followed by two integers , (). It means that you should print .
For each query of type , print one real number — the answer to the query. Your answer is considered correct if its absolute error or relative error does not exceed .
No comments:
Post a Comment