305057: CF958F1. Lightsabers (easy)

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Lightsabers (easy)

题目描述

There is unrest in the Galactic Senate. Several thousand solar systems have declared their intentions to leave the Republic. Master Heidi needs to select the Jedi Knights who will go on peacekeeping missions throughout the galaxy. It is well-known that the success of any peacekeeping mission depends on the colors of the lightsabers of the Jedi who will go on that mission. Heidi has $ n $ Jedi Knights standing in front of her, each one with a lightsaber of one of $ m $ possible colors. She knows that for the mission to be the most effective, she needs to select some contiguous interval of knights such that there are exactly $ k_{1} $ knights with lightsabers of the first color, $ k_{2} $ knights with lightsabers of the second color, $ ... $ , $ k_{m} $ knights with lightsabers of the $ m $ -th color. Help her find out if this is possible.

输入输出格式

输入格式


The first line of the input contains $ n $ ( $ 1<=n<=100 $ ) and $ m $ ( $ 1<=m<=n $ ). The second line contains $ n $ integers in the range $ {1,2,...,m} $ representing colors of the lightsabers of the subsequent Jedi Knights. The third line contains $ m $ integers $ k_{1},k_{2},...,k_{m} $ (with ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF958F1/35fb4fe66d9c5af5cfc16ee37846c2adee7f43fd.png)) – the desired counts of lightsabers of each color from $ 1 $ to $ m $ .

输出格式


Output YES if an interval with prescribed color counts exists, or output NO if there is none.

输入输出样例

输入样例 #1

5 2
1 1 2 2 1
1 2

输出样例 #1

YES

Input

暂时还没有翻译

加入题单

算法标签: