It is Christmas day and kind-hearted gentle Ebenezer Scrooge has waken up from his life of greed.
The 3 spirits of Christmas have changed his ways with great speed.
Promptly departing for the house of Bob Cratchit, he declares himself a reformed man and joins them for Christmas day lunch.
He offers a wealth of money for Bob Cratchit, to be used for Tiny Tim's health, who is playing in the corner all hunched.
"Can I join you?" asks Ebenezer Scrooge.
Ebenezer Scrooge is playing with Bob Cratchit's youngest son, Tiny Tim, and they have decided to play a fun game of dominoes! In this version of dominoes, the goal is to build a straight line of dominoes so that when the first one in the line is knocked down, it will knock down the rest of the dominoes. To make it fun for Tim, Scrooge has decided to let Tiny Tim place some domino holders at certain positions and Scrooge has to place the dominos in the holders.
To start this game off, Ebenezer Scrooge will draw a line on the ground from where the line of dominoes will start. Then Tiny Tim will set down individual domino holders placed at position from the start line, with one domino holder guaranteed to be on the start line (). Ebenezer Scrooge has exactly dominoes, each of some length , and will attempt to place each domino in a domino holder so that when the domino at the start line is knocked down, it touches the next domino in the line, knocking it down.
A domino at position with length will knock down all dominoes in the range .
Given Tiny Tim's positioning of the domino holders starting, in order, from the start line and the size of each domino, is it possible for Ebenezer Scrooge to meet the goal of the game? Note that Scrooge must put a domino in every holder.
Input Specifications
The first line will contain two integers , where .
The second line will contain integers, where .
The third line will contain distinct integers, where .
Solutions in Java are encouraged to use fast input reading.
Output Specifications
Output "yes" if Ebenezer Scrooge can knock down all the dominos or "no" otherwise.
Sample Input
4 4
2 1 4 1
0 2 3 7
Sample Output
yes
Explanation
The domino holders are positioned as such (where h
is a holder and _
is an empty spot:
h_hh___h
The first holder should contain the domino of length 2, the second holder length 1, third length 4, and fourth length 1.
Comments