| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 2048 MB | 12 | 6 | 4 | 40.000% |
Morgan the robot has an array $A$ of size $N$, indexed from $1$ to $N$. The value of each element in $A$ is randomly generated; $A_i$ can be any integer from $L_i$ to $R_i$ (inclusive) with equal probability.
Morgan defines the beauty of $A$ as follows. First, Morgan has a variable named score that is initialized to $0$. An operation on the array $a$ is as follows:
score and remove $a_i$ from the array.The beauty of $A$ is the maximum value of score$^2$ Morgan can possibly get after performing zero or more operations on the array $A$.
Since the array is randomly generated, Morgan wonders about the expected beauty of $A$. Due to the inefficiency of his algorithm, Morgan asks for your help to calculate the expected value.
Input begins with an integer $N$ ($1 ≤ N ≤ 200\, 000$) representing the size of array $A$. Each of the next $N$ lines contains two integers $L_i$ $R_i$ ($1 ≤ L_i ≤ R_i ≤ 10^8$).
Let $M = 998\, 244\, 353$. It can be shown that the expected value can be expressed as an irreducible fraction $\frac{p}{q}$, where $p$ and $q$ are integers and $q \not\equiv 0 \bmod M$. Output an integer $x$ in a single line such that $0 ≤ x < M$ and $x \cdot q \equiv p \bmod M$.
3 1 2 2 3 1 3
831870298
There are $12$ possibilities of $A$. Out of all possibilities, the following has positive beauty.
Therefore, the expected beauty of $A$ is $(4 + 9 + 4 + 16 + 4 + 9)/12 = \frac{46}{12} = \frac{23}{6}$. Since $831\, 870\, 298 \cdot 6 \equiv 23 \bmod 998\, 244\, 353$, you need to output $831\, 870\, 298$.
4 1 1 1 1 2 2 2 2
9
The only possible value of $A$ is $[1, 1, 2, 2]$ with a beauty of $(1 + 2)^2 = 9$.
3 1 2 3 4 5 6
0
ICPC > Regionals > Asia Pacific > Indonesia > Indonesia National Contest > INC 2022 L번