QOJ.ac

QOJ

実行時間制限: 2 s メモリ制限: 256 MB 満点: 100

#16291. 监督

統計

在奶牛夏令营中有 $N$($1\le N \leq 10^6$)只奶牛,编号为 $1\dots N$。每只奶牛要么是营员(camper),要么是教练(coach)。

将选择一个非空的奶牛子集去参加野外旅行。如果第 $i$ 只奶牛被选中,它将移动到数轴上的位置 $p_i$($0\le p_i \leq 10^9$),其中数组 $p$ 是严格递增的。

一个非空奶牛子集被称为“优秀的”(good),如果对于每个被选中的营员,在它左侧距离不超过 $D$ 的范围内(含边界)都存在至少一个被选中的教练(即如果被选中的营员在 $p_i$,则在 $[p_i - D, p_i]$ 范围内必须存在一个被选中的教练,$0\le D\le 10^9$)。问有多少个优秀的子集,模 $10^9+7$ 的余数是多少?

输入格式

第一行包含两个整数 $N$ 和 $D$。

接下来的 $N$ 行,每行包含两个整数 $p_i$ 和 $o_i$。$p_i$ 表示第 $i$ 只奶牛将移动到的位置。$o_i=1$ 表示第 $i$ 只奶牛是教练,而 $o_i=0$ 表示第 $i$ 只奶牛是营员。

保证 $p_i$ 是按严格递增的顺序给出的。

输出格式

输出优秀的子集数量模 $10^9 + 7$ 的结果。

样例

输入样例 1

6 1
3 1
4 0
6 1
7 1
9 0
10 0

输出样例 1

11

说明

最后两个营员永远无法被选中。所有其他非空子集只要满足“如果奶牛 $2$ 被选中,则奶牛 $1$ 也必须被选中”即可。

输入样例 2

20 24
3 0
14 0
17 1
20 0
21 0
22 1
28 0
30 0
32 0
33 1
38 0
40 0
52 0
58 0
73 0
75 0
77 1
81 1
84 1
97 0

输出样例 2

13094

子任务

  • 测试点 3:$N=20$
  • 测试点 4:$D=0$
  • 测试点 5-8:$N\le 5000$
  • 测试点 9-16:无附加限制。

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.