CF1076F.Summer Practice Report
普及/提高-
通过率:0%
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 n pages and the i -th page will include xi tables and yi formulas. The pages are numbered from 1 to n .
Vova fills the pages one after another, he can't go filling page i+1 before finishing page i and he can't skip pages.
However, if he draws strictly more than k tables in a row or writes strictly more than k 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 3 tables and the next page starts with 5 tables, then it's counted as 8 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 k tables in a row and no more than k formulas in a row.
输入格式
The first line contains two integers n and k ( 1≤n≤3⋅105 , 1≤k≤106 ).
The second line contains n integers x1,x2,…,xn ( 1≤xi≤106 ) — the number of tables on the i -th page.
The third line contains n integers y1,y2,…,yn ( 1≤yi≤106 ) — the number of formulas on the i -th page.
输出格式
Print "YES" if Vova can rearrange tables and formulas on each page in such a way that there is no more than k tables in a row and no more than k formulas in a row.
Otherwise print "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 1 : "TTFTTFT"
- page 2 : "TFTTFTT"
That way all blocks of tables have length 2 .
In the second example there is no way to fit everything in such a way that there are no more than 2 tables in a row and 2 formulas in a row.