No.1205 Eye Drops
タグ : / 解いたユーザー数 275
作問者 :
kaage
/ テスター :
penguinman
Problem Statement
There are $N$ consecutive sections, numbered from $0$ to $N-1$.
Kaage is currently in section $0$, and the time is $0$.
Kaage can move to an adjacent section in $1$ unit of time.
That is, if he is in section $i$ at time $t$, then at time $t+1$ he can stay at $i$ or move to $i-1,i+1$ (if they exist).
You are now given $M$ pieces of information of the form "at time $T_i$, eye drops fall from the second floor onto section $P_i$".
By moving appropriately, can Kaage catch all the eye drops at the times they fall?
Here, Kaage can also catch the eye drops falling at the moment he has just arrived at a section.
Input
$N\ M$
$T_1\ P_1$
$T_2\ P_2$
$\vdots$
$T_M\ P_M$
- $1\leq N,M\leq 10^5$
- $0\leq P_i\leq N-1$
- $0\leq T_i\leq 10^{10}$
- $T_i\leq T_{i+1}(0\leq i< M-1)$
- All input values are integers.
Output
Print "Yes" if Kaage can catch all the eye drops, and "No" otherwise, on one line.
Sample
Sample 1
Input
3 2
1 0
4 2
Output
Yes
Sample 2
Input
2 1
0 1
Output
No
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。