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] Placing Jinas Codeforces Solution | Codeforces Problem Solution 2022


E. Placing Jinas
time limit per test
2 seconds
memory limit per test
512 megabytes
input
standard input
output
standard output

We say an infinite sequence a0,a1,a2, is non-increasing if and only if for all i0aiai+1.

There is an infinite right and down grid. The upper-left cell has coordinates (0,0). Rows are numbered 0 to infinity from top to bottom, columns are numbered from 0 to infinity from left to right.

There is also a non-increasing infinite sequence a0,a1,a2,. You are given a0a1an; for all i>nai=0. For every pair of xy, the cell with coordinates (x,y) (which is located at the intersection of x-th row and y-th column) is white if y<ax and black otherwise.

Initially there is one doll named Jina on (0,0). You can do the following operation.

  • Select one doll on (x,y). Remove it and place a doll on (x,y+1) and place a doll on (x+1,y).


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

Note that multiple dolls can be present at a cell at the same time; in one operation, you remove only one. Your goal is to make all white cells contain 0 dolls.

What's the minimum number of operations needed to achieve the goal? Print the answer modulo 109+7.

Input

The first line of input contains one integer n (1n2105).

The second line of input contains n+1 integers a0,a1,,an (0ai2105).

It is guaranteed that the sequence a is non-increasing.

Output

Print one integer — the answer to the problem, modulo 109+7.

No comments:

Post a Comment