Logo
(追記) (追記ここまで)

34591번 - Chopsticks 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 2048 MB235526.316%

문제

Chisato works at a traditional Japanese restaurant that just received a shipment of beautifully handcrafted chopsticks. There are $m$ different types of chopsticks, and for each type $i$ (1ドル ≤ i ≤ m$), there are exactly $k_i$ chopsticks.

Tonight, $n$ guests have arrived, and each guest needs exactly one pair of chopsticks. Since no type of chopstick has at least 2ドルn$ pieces, Chisato decides to randomly select 2ドルn$ chopsticks from the full collection, which contains $s = \sum_{i=1}^{m}{k_i}$ chopsticks in total.

After selecting the 2ドルn$ chopsticks, Chisato will try to distribute them in a way that maximizes the number of guests receiving a matching pair, that is, two chopsticks of the same type. If it’s not possible to provide matching pairs for everyone, some guests will receive mismatched pairs.

Your task is to compute the expected number of guests who receive mismatched pairs of chopsticks under this strategy.

입력

The first line contains two integers $n$ and $m,ドル representing the number of people and the number of the chopstick type, respectively.

The second line contains $m$ integers, the $i$-th integer $k_i$ represents the number of chopstick for the $i$-th type.

출력

Print a single integer, the expected number of people who cannot get a pair of chopsticks of the same type, multiplied by $\displaystyle\binom{s}{2n}$ (where $s = \sum_{i=1}^{m}{k_i}$). It can be proven that this product is an integer. Output the result modulo 998244353ドル$.

제한

  • 1ドル ≤ n ≤ 2.5 \times 10^5$
  • 1ドル ≤ m ≤ 5 \times 10^5$
  • 1ドル ≤ k_i < 2 \times n$
  • 2ドル \times n ≤ s$

예제 입력 1

3 3
2 2 2

예제 출력 1

0

예제 입력 2

5 3
3 3 4

예제 출력 2

1

예제 입력 3

5 2
8 8

예제 출력 3

4032

노트

출처

ICPC > Regionals > Asia Pacific > Taiwan > Taiwan Online Programming Contest > TOPC 2025 H번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /