A12223 | Summer Practice Report
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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 $x_i$ tables and $y_i$ 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.
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 $x_i$ tables and $y_i$ 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 \le n \le 3 \cdot 10^5$ , $1 \le k \le 10^6$ ).
The second line contains $n$ integers $x_1, x_2, \dots, x_n$ ( $1 \le x_i \le 10^6$ ) — the number of tables on the $i$ -th page.
The third line contains $n$ integers $y_1, y_2, \dots, y_n$ ( $1 \le y_i \le 10^6$ ) — the number of formulas on the $i$ -th page.
The second line contains $n$ integers $x_1, x_2, \dots, x_n$ ( $1 \le x_i \le 10^6$ ) — the number of tables on the $i$ -th page.
The third line contains $n$ integers $y_1, y_2, \dots, y_n$ ( $1 \le y_i \le 10^6$ ) — 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".
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.
- 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.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted