one maneuver, the robot should move one cell to the left or right, given that it doesn't move beyond the field of play. As such, if the robot was in the cell I, it should move to either the cell i−1 or the cell i+1, as long as it lies among 1 and n (endpoints comprehensive). The cells, in the request they

Operations Research : Applications and Algorithms
4th Edition
ISBN:9780534380588
Author:Wayne L. Winston
Publisher:Wayne L. Winston
Chapter19: Probabilistic Dynamic Programming
Section19.4: Further Examples Of Probabilistic Dynamic Programming Formulations
Problem 7P
icon
Related questions
Question

Correct answer will be upvoted else Multiple Downvoted. Computer science.

one maneuver, the robot should move one cell to the left or right, given that it doesn't move beyond the field of play. As such, if the robot was in the cell I, it should move to either the cell i−1 or the cell i+1, as long as it lies among 1 and n (endpoints comprehensive). The cells, in the request they are visited (counting the cell the robot is set), together make a decent way. 

 

Every cell I has a worth computer based intelligence related with it. Let c0,c1,… ,ck be the succession of cells in a decent way in the request they are visited (c0 is the cell robot is at first positioned, c1 is the cell where the robot is after its first move, etc; all the more officially, ci is the cell that the robot is at after I moves). Then, at that point, the worth of the way is determined as ac0+ac1+⋯+ack. 

 

Your errand is to work out the amount of qualities over all conceivable great ways. Since this number can be extremely enormous, output it modulo 109+7. Two great ways are considered unique if the beginning cell contrasts or there exists an integer i∈[1,k] with the end goal that the current cell of the robot after precisely I moves is diverse in those ways. 

 

You should handle q updates to an and print the refreshed total each time. Each update changes the worth of precisely one cell. See the input design and the example input-output for additional subtleties. 

 

Input 

 

The main line of the input contains three space-isolated integers n, k and q (2≤n≤5000; 1≤k≤5000; 1≤q≤2⋅105). 

 

The second line of the input contains n integers a1,a2,… ,an (1≤ai≤109). 

 

q lines follow. Each line contains two space-isolated integers I and x (1≤i≤n; 1≤x≤109) showing that you should change the worth of man-made intelligence to x. 

 

Output 

 

Print q integers. The I-th integer ought to be the amount of qualities over all great ways after the primary I refreshes are performed. Since the appropriate responses might be enormous, print them modulo 109+7.

 

 

Expert Solution
steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Knowledge Booster
Processes of 3D Graphics
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Operations Research : Applications and Algorithms
Operations Research : Applications and Algorithms
Computer Science
ISBN:
9780534380588
Author:
Wayne L. Winston
Publisher:
Brooks Cole