Library game
시간 제한2초메모리 제한1024 MB
Bernardo가 같은 주제의 책 두 권을 확보할 수 있는지, 아니면 Alessia가 구간을 골라 이를 막을 수 있는지 판정하는 문제다.
문제
Alessia and Bernardo are discovering the world of competitive programming through the books of their university library.
The library consists of sections numbered from to . Each section contains only books dedicated to a particular subject and different sections correspond to different subjects. In order to prevent the students from wandering in the library, the university has established a system of passes. Each pass has a length associated to it and allows access to an interval of consecutive sections in the library. During a visit, the student must choose exactly one book from one of these sections and leave the library. Each pass can be used only once.
At the moment Alessia and Bernardo have passes of lengths . They have different opinions on the best way to improve: Alessia thinks that it is important to study many different topics, while Bernardo believes that it is important to study deeply at least one topic. So, Alessia wants to use the passes to get books on distinct topics, while Bernardo would like to get at least two books on the same topic.
They have reached the following agreement: for each of the following days, Alessia will choose a pass of length among those which are still available and an interval of sections in the library, and Bernardo will go into the library and will take exactly one book from one of those sections.
Can Bernardo manage to get at least two books on the same subject, or will Alessia be able to avoid it?
You should decide whether you want to be Alessia or Bernardo, and you have to fulfill the goal of your chosen character. The judge will impersonate the other character. Note that, even if at some moment Bernardo has already taken two books on the same subject, the interaction should go on until the end of the days.
입력
The first line contains two integers and (, ) — the number of passes and the number of sections.
The second line contains integers () — the lengths of the passes available.