No.2433 Min Increasing Sequence
Problem Statement
You are given a sequence $A=(A_1, A_2, \cdots, A_N)$ of length $N$.
There are $2^{N-1}$ ways to split $A$ into some number of non-empty contiguous subarrays. Among them, find the number of splits satisfying the following condition, modulo $998244353$.
- If $A$ is split into $B_1, B_2, \cdots,B_K$, then $(\min{B_1}, \min{B_2}, \cdots, \min{B_K})$ is a non-decreasing sequence.
Here, for a non-empty sequence $B$, $\min{B}$ denotes the minimum value of its elements.
Constraints
- $1\leq N\leq 2\times{10}^5$
- $1\leq A_i\leq {10}^9$
- All input values are integers.
Input
$N$ $A_1$ $A_2$ $\cdots$ $A_N$
Output
Print the number of splits satisfying the condition, modulo $998244353$.
Sample
Sample 1
Input
3 1 3 2
Output
3
There are $3$ splits satisfying the condition, as follows.
- $(1, 3, 2)$
- $(1), (3, 2)$
- $(1, 3), (2)$
Sample 2
Input
3 3 2 1
Output
1
Sample 3
Input
10 4 1 2 6 1 3 9 10 1 3
Output
40
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
noya2