Universal Cup Judging System

Universal Cup

Süre Sınırı: 5 s Bellek Sınırı: 2048 MB Toplam puan: 100
İstatistikler

在人工智慧崛起的時代,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$ 的試驗,AI 會獲得 $a_i - h_i$ 分。如果人類的總分大於或等於 AI 的總分乘以某個常數 $k$(用來考量人類需要食物、水和辦公桌的成本),James 的老闆就會宣布人類的表現優於 AI。

James 計畫透過電子郵件將他所選的測試結果子序列發送給老闆。然而,有一個複雜的情況:由於 AI 已經無所不知、無所不在,它會攔截這封郵件,並可能任選一次試驗 $i$,將 $h_i$ 和 $a_i$ 的值互換。(它不想交換超過一次試驗的結果——否則 James 可能會察覺到!)

請計算有多少個非空連續的試驗結果子序列,能讓 James 發送給老闆後,即使 AI 最多交換一次試驗的結果,依然能保證老闆會宣布人類的表現優於 AI。

輸入格式

輸入的第一行包含兩個以空格分隔的整數:$N$($1 \le N \le 2 \cdot 10^5$),代表 James 進行的試驗總數;以及 $k$($1 \le k \le 100$),代表 James 的老闆為了判斷人類是否優於 AI 而對 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.