Wooden Board
Time limit5sMemory limit1024 MB
Given N trees with daily growth chances in percent, find the expected area of the largest rectangle under the tree heights after M days, modulo 998244353.
- Level
Medium7 of 10
- Topics
- Dynamic programming, Probability, Divide and conquer
- Solved
- No attempts yet
Problem
trees are planted in a straight line, each unit apart.
On day , every tree has height . Each tree has width . At the start of each day, the -th tree grows by compared to the previous day with probability percent. Otherwise, it keeps the same height as the previous day.
You want to cut the largest rectangular region covered by the trees to get a large wooden board. The two sides of the board must be parallel to the ground.

For example, when 5 trees are planted and their heights are 1, 4, 2, 5, 3 in order, the board size is 8.
Find the expected area of the wooden board you can obtain on day . See the Output section for the output format.
Input
The first line contains the number of trees and the number of days .
The second line contains the growth percentages of each tree per day.
All input values are guaranteed to be integers.
Output
The expected area is a rational number. When it is written as an irreducible fraction , is guaranteed not to be a multiple of . Then there is exactly one integer such that . Print this .