GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

Saturday 25 June 2022

[Solution] Fishingprince Plays With Array Again Codeforces Solution


G. Fishingprince Plays With Array Again
time limit per test
6 seconds
memory limit per test
1024 megabytes
input
standard input
output
standard output

Suppose you are given a 1-indexed sequence a of non-negative integers, whose length is n, and two integers xy. In consecutive t seconds (t can be any positive real number), you can do one of the following operations:

  • Select 1i<n, decrease ai by xt, and decrease ai+1 by yt.
  • Select 1i<n, decrease ai by yt, and decrease ai+1 by xt.

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=1y=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.

Solution Click Below:-  👉CLICK HERE👈
👇👇👇👇👇


Now you are given a 1-indexed sequence b of positive integers, whose length is n. You are also given positive integers xy. Process q queries of the following two types:

  • 1 k v: change bk to v.
  • 2 l r: print f([bl,bl+1,,br]).
Input

The first line of input contains two integers n and q (2n21051q2105).

The second line of input contains two integers x and y (1x,y106).

The third line of input contains n integers b1,b2,,bn (1bi106).

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 kv (1kn1v106). It means that you should change bk to v.
  • If it is 2, it is followed by two integers lr (1l<rn). It means that you should print f([bl,bl+1,,br]).
Output

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 109.

No comments:

Post a Comment