Reality of Semnan


  • محدودیت زمان: ۱ ثانیه
  • محدودیت حافظه: ۲۵۶ مگابایت

In Semnan, n houses are arranged in a row. Since everyone doubts that Semnan might be imaginary and doesn’t really exist, Sehri, a famous witch, has hired k experts to verify the existence of the houses in Semnan. The i-th expert has a starting position indiind_i. where Sehri appears the i-th expert exactly on house indiind_i. After the starting house is verified by the i-th expert, now they can either see and verify all the houses to the right of them, or all the houses to the left of them. in other words, the i-th expert can verify houses indi,indi+1,...,nind_i, ind_i+1, ..., n or verify the the houses 1,2,...,indi1, 2, ..., ind_i note that Sehri will appear experts in different starting houses.

to verify the existence of the i-th house from the right, at least aia_i experts must have verify it.

Sehri wants to know if, among all the possible cases where each expert chooses either the left or the right side, there is a situation where we can be sure that all the houses in Semnan exist?

input🔗

the first line consist nn and kk the number of houses in Semnan that arranged in a row and the number of experts. the next line consist of n numbers. aia_i shows the number of experts should verify house number i. then in the next line of the input there is k different numbers ind_i that shows the starting houses.

1kn200,0001 \le k \le n \le 200,000 1aik1 \le a_i \le k 1indin1 \le ind_i \le n

output🔗

your output should consist YES if experts can verify Semnan houses or NO if they cant.

example🔗

sample input 1🔗

7 3
0 0 3 0 3 0 1
3 4 7
Plain text

sample output 1🔗

NO
Plain text

sample input 2🔗

7 3
0 0 2 0 3 0 1
3 4 7
Plain text

sample output 2🔗

YES
Plain text
ارسال پاسخ برای این سؤال
در حال حاضر شما دسترسی ندارید.