Universal Cup Judging System

Universal Cup

実行時間制限: 5 s メモリ制限: 2048 MB 満点: 100
統計

在人工智能崛起的时代,James 很担心丢掉工作。因此,当他的老板要求他评估一个新的 AI 模型,看看它与人类相比表现如何时,他想让这个 AI 看起来尽可能糟糕。

为了测试 AI,James 进行了 $N$ 次试验,人类和 AI 在每次试验中完成相同的任务,并根据任务表现进行评分。随后,他打算将这些试验中某个非空连续子序列的结果发送给老板,并悄悄删除其余部分。

设 $a_i$ 和 $h_i$ 分别为 AI 和人类在第 $i$ 次试验中的表现。James 的老板通过计算两个总分来评估 AI 在一系列试验中的表现:一个是人类的总分,另一个是 AI 的总分。两个分数初始均为 0。对于每个 $h_i \ge a_i$ 的试验 $i$,老板奖励人类 $h_i - a_i$ 分。对于每个 $h_i < a_i$ 的试验 $i$,AI 获得 $a_i - h_i$ 分。如果人类的总分大于或等于 AI 的总分乘以某个常数 $k$(以补偿人类需要食物、水和办公桌的开销),James 的老板就会宣布人类的表现优于 AI。

James 计划通过电子邮件将他选择的测试结果子序列发送给老板。然而,有一个复杂的情况:由于 AI 已经无所不知、无处不在,它会拦截这封邮件,并可能选择任意一次试验 $i$,交换 $h_i$ 和 $a_i$ 的值。(它不想交换超过一次试验的结果——否则 James 可能会察觉到!)

请计算有多少个非空连续试验子序列,使得即使 AI 最多交换一次试验结果,James 发送给老板后,老板依然会宣布人类的表现优于 AI。

输入格式

第一行包含两个空格分隔的整数:$N$ ($1 \le N \le 2 \cdot 10^5$),即 James 进行的试验总数;以及 $k$ ($1 \le k \le 100$),即老板用来确定人类是否优于 AI 的乘数。

第二行包含 $N$ 个空格分隔的整数 $h_1, h_2, \dots, h_N$ ($0 \le h_i \le 10^6$),表示人类在 $N$ 次试验中每次的表现。

第三行包含 $N$ 个空格分隔的整数 $a_1, a_2, \dots, a_N$ ($0 \le a_i \le 10^6$),表示 AI 在 $N$ 次试验中每次的表现。

输出格式

输出非空连续试验子序列的数量,使得即使 AI 最多交换一次试验结果,James 的老板依然会宣布人类的表现优于 AI。

样例

样例输入 1

10 2
3 5 7 6 8 6 4 5 2 6
2 4 6 5 4 3 3 6 3 4

样例输出 1

4

样例输入 2

7 1
4 3 2 1 7 6 5
4 2 3 1 7 6 5

样例输出 2

11

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.