CF1076F.Summer Practice Report

省选/NOI-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Vova has taken his summer practice this year and now he should write a report on how it went.

Vova has already drawn all the tables and wrote down all the formulas. Moreover, he has already decided that the report will consist of exactly nn pages and the ii-th page will include xix_i tables and yiy_i formulas. The pages are numbered from 11 to nn.

Vova fills the pages one after another, he can't go filling page i+1i + 1 before finishing page ii and he can't skip pages.

However, if he draws strictly more than kk tables in a row or writes strictly more than kk formulas in a row then he will get bored. Vova wants to rearrange tables and formulas in each page in such a way that he doesn't get bored in the process. Vova can't move some table or some formula to another page.

Note that the count doesn't reset on the start of the new page. For example, if the page ends with 33 tables and the next page starts with 55 tables, then it's counted as 88 tables in a row.

Help Vova to determine if he can rearrange tables and formulas on each page in such a way that there is no more than kk tables in a row and no more than kk formulas in a row.

沃瓦今年参加了暑期实习,现在他需要撰写一份实习报告。

沃瓦已经画好了所有表格,并写下了全部公式。此外,他已确定报告恰好由 nn 页组成,其中第 ii 页包含 xix_i 个表格和 yiy_i 个公式。页面编号从 11 到 nn。

沃瓦按顺序逐页填写报告:他不能在完成第 ii 页之前开始填写第 i+1i + 1 页,也不能跳过任何一页。

然而,如果他连续绘制的表格数量严格超过 kk 个,或连续书写的公式数量严格超过 kk 个,则他会感到厌烦。沃瓦希望在每一页内重新安排表格与公式的顺序,使得整个填写过程中不会感到厌烦。但沃瓦不能将某个表格或某个公式移动到其他页面。

注意:计数在新页面开始时不会重置。例如,若某页以 33 个表格结尾,而下一页以 55 个表格开头,则这被视为连续 88 个表格。

请帮助沃瓦判断:能否通过在每一页内重新安排表格与公式的顺序,使得在整个过程中既不存在连续超过 kk 个表格,也不存在连续超过 kk 个公式。

输入格式

The first line contains two integers nn and kk (1≤n≤3⋅1051 \le n \le 3 \cdot 10^5, 1≤k≤1061 \le k \le 10^6).

The second line contains nn integers x1,x2,…,xnx_1, x_2, \dots, x_n (1≤xi≤1061 \le x_i \le 10^6) — the number of tables on the ii-th page.

The third line contains nn integers y1,y2,…,yny_1, y_2, \dots, y_n (1≤yi≤1061 \le y_i \le 10^6) — the number of formulas on the ii-th page.

第一行包含两个整数 nn 和 kk(1≤n≤3⋅1051 \le n \le 3 \cdot 10^5,1≤k≤1061 \le k \le 10^6)。

第二行包含 nn 个整数 x1,x2,…,xnx_1, x_2, \dots, x_n(1≤xi≤1061 \le x_i \le 10^6)——第 ii 页上的表格数量。

第三行包含 nn 个整数 y1,y2,…,yny_1, y_2, \dots, y_n(1≤yi≤1061 \le y_i \le 10^6)——第 ii 页上的公式数量。

输出格式

Print "YES" if Vova can rearrange tables and formulas on each page in such a way that there is no more than kk tables in a row and no more than kk formulas in a row.

Otherwise print "NO".

如果沃瓦能够重新排列每页上的表格和公式,使得任意连续的表格数量不超过 kk 个,且任意连续的公式数量也不超过 kk 个,则输出 "YES";
否则输出 "NO"。

输入输出样例

  • 输入#1

    2 2
    5 5
    2 2

    输出#1

    YES
  • 输入#2

    2 2
    5 6
    2 2

    输出#2

    NO
  • 输入#3

    4 1
    4 1 10 1
    3 2 10 1

    输出#3

    YES

说明/提示

In the first example the only option to rearrange everything is the following (let table be 'T' and formula be 'F'):

  • page 11: "TTFTTFT"
  • page 22: "TFTTFTT"

That way all blocks of tables have length 22.

In the second example there is no way to fit everything in such a way that there are no more than 22 tables in a row and 22 formulas in a row.

在第一个例子中,唯一一种重新排列所有内容的方式如下(设表格为“T”,公式为“F”):

  • 第 1 页:“TTFTTFT”
  • 第 2 页:“TFTTFTT”

这样,所有表格连续块的长度均为 22。

在第二个例子中,不存在一种安排方式,使得任意连续的表格数量不超过 22 个,且任意连续的公式数量也不超过 22 个。

输入解题思路,AI测评打分。不知道怎么写?

首页