QOJ.ac

QOJ

Límite de tiempo: 1 s Límite de memoria: 512 MB Puntuación total: 100

#3164. 全歼

Estadísticas

你刚刚和你的朋友参加了一场编程竞赛。遗憾的是,你们没能“全场通杀”(即解决所有题目),但你现在想知道是否有一种策略可以解决所有题目。

解决一个问题分为两个阶段:思考阶段和编码阶段。你的朋友负责所有的思考,而你负责所有的编码。

对于每一道题,你已经计算出了你编码它所需的精确时间。然而,在竞赛中编码一道题之前,你的朋友必须先想出解题思路。你不确定该如何估计朋友想出解题思路的时间,因此你将其建模如下:对于每一道题,你的朋友在竞赛期间的某一个分钟内想出解题思路的概率是均匀分布的。这些时间点是相互独立的随机变量。你一次只能编码一道题,因此在任何时刻都可能有几道题在排队等待编码。你总是优先编码编号较小的题目。你按分钟进行操作,所以如果你的朋友在你完成一道编号较大的题目的编码之前,就想出了编号较小的题目的解题思路,你就会切换去编码那道编号较小的题目,但你并不希望这样做。即使是在人类大脑中,上下文切换也是一项昂贵的操作!

竞赛策略可以针对每一分钟建模如下:

  • 对于每一道尚未有解题思路的题目,你的朋友在这一分钟内想出解题思路的概率为 $1/(\text{竞赛剩余分钟数})$。你的朋友可以在同一分钟内想出多道题的解题思路。
  • 在那些仍然需要编码时间且你的朋友已经想出解题思路的题目中,你会选择编号最小的一道,并花费接下来的一分钟编码它(如果没有题目满足条件,则这一步什么都不做)。

你想要知道以下两个事件同时发生的概率:

  • 你们团队在竞赛结束前完成了所有题目的编码。
  • 对于每一道题,编码该题所花费的时间是一个连续的时间区间。

设 $p$ 为该概率,$n$ 为竞赛中的题目数量,$t$ 为竞赛的总分钟数。可以证明 $p \cdot t^n$ 是一个整数。输出 $(p \cdot t^n) \pmod{998,244,353}$ 的值。注意 $998,244,353$ 是一个大质数。

输入格式

输入的第一行包含两个空格分隔的整数 $n$ ($1 \le n \le 10^5$) 和 $t$ ($1 \le t \le 10^8$),其中 $n$ 是竞赛中的题目数量,$t$ 是竞赛的总分钟数。

接下来的 $n$ 行,每行包含一个整数 $x$ ($1 \le x \le 10^3$)。这些是按顺序编码每道题所需的分钟数。保证这些时间的总和小于或等于 $t$。

输出格式

输出一个整数,即 $(p \cdot t^n) \pmod{998,244,353}$,其中 $p$ 是上述两个事件同时发生的概率。

样例

样例输入 1

3 5
1
2
1

样例输出 1

60

样例输入 2

5 5
1
1
1
1
1

样例输出 2

1296

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.