問題一覧 > 通常問題

No.2875 What is My Rank?

レベル : / AI推定難易度 : 1450 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 50
作問者 : 寝癖 / テスター : 👑 seekworser yuusaan
お気に入りにしたユーザー ProblemId : 11167 / 自分の提出
問題文最終更新日: 2024-09-06 21:46:10
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 444 (順位表) の他の問題:

Problem Statement

Neguse-kun participated in a marathon-style contest.

This contest had $N$ participants including Neguse-kun, and the $1$-st participant is Neguse-kun.

In the contest, it is known that the $i\ (1\le i \le N)$-th participant obtains a score that is an integer between $l_i$ and $r_i$, inclusive, with each value being equally likely.

After the contest ends, ranks are assigned in descending order of score, and in case of a tie, the person with the smaller number gets the higher rank.

Find the expected value of Neguse-kun's rank, $\rm mod 998244353$.

Definition of expected value $\bmod \ 998244353$ It can be proved that the expected value sought in this problem is always a rational number. Also, under the constraints of this problem, when the probability sought is represented as an irreducible fraction $\frac{y}{x}$, there uniquely exists an integer $0 \le z < 998244353$ such that $xz \equiv y \quad ( \bmod \ 998244353 )$. Output this $z$.

Input

$N$
$l_1\ r_1$
$l_2\ r_2$
$\vdots$
$l_N\ r_N$

Constraints

  • $1\le N \le 2\times 10^5$
  • $1\le l_i \le r_i \le 10^9,\ i=1,2,\dots,N$
  • $r_i-l_i+1\neq 998244353,\ i=1,2,\dots,N$
  • All inputs are integers.

Output

Output the expected value of Neguse-kun's rank, $\rm mod 998244353$, on one line.

Sample

Sample 1
Input
3
5 5
1 2
5 7
Output
665496237

The scores of persons $1,2,3$ have $6$ possibilities, $(5,1,5),(5,1,6),(5,1,7),(5,2,5),(5,2,6),(5,2,7)$, and each of them occurs with equal probability.

Neguse-kun's ranks are $1,2,2,1,2,2$ respectively, so the expected value of the rank is $\frac{1+2+2+1+2+2}{6}=\frac{5}{3}$.

Sample 2
Input
1
1 1
Output
1
Sample 3
Input
4
1 10
1 10
1 10
1 10
Output
49912220

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。