Vanya and Jackets

시간 제한2초메모리 제한1024 MB

요약
각 날짜의 기온을 포함하는 재킷을 배정하되, 연속한 두 날에는 같은 재킷을 입지 않도록 일정을 만든다.
난이도

보통10점 중 7점

유형
그리디, 정렬, 투 포인터
정답자
아직 제출이 없습니다

문제

Vanya attempted to change his life once again and decided to create a schedule of jackets he is going to wear during the next nn days.

He read several manuals on jackets operation and found out that different jackets are designed for different temperature ranges. For each of his mm jackets he determined values of l_il\_i and r_ir\_i, the minimum and maximum temperature value that admits wearing the ii-th jacket.

Vanya knows the weather forecast for the next nn days, namely there will be the temperature of a_ja\_j during the jj-th day. Since Vanya is sane enough, he will choose the appropriate jacket for each temperature, that is, on the jj-th day he will wear any jacket ii such that l_i≤a_j≤r_il\_i \leq a\_j \leq r\_i. Also, Vanya tries to be really fashionable, so he never wears the same jacket for two consecutive days.

Given the fact that Vanya's mother does not allow him leaving home without the jacket or wearing several jackets, create a schedule of which jackets he should wear during the next nn days satisfying all the requirements of Vanya.

입력

The first line of the input contains two integers nn and mm (1≤n,m≤100,0001 \leq n, m \leq 100\\,000), the number of days and the number of jackets in Vanya's wardrobe respectively.

The second line of the input contains nn integers a_ia\_i (0≤a_i≤1090 \leq a\_i \leq 10^9), the temperature at the ii-th day.

Then mm lines follow, ii-th of them contains two integers l_il\_i and r_ir\_i (0≤l_i≤r_i≤1090 \leq l\_i \leq r\_i \leq 10^9), defining the temperature range of the ii-th jacket.

출력

If there exists a way of choosing a jacket for each of the nn days, output the word "Yes" (without the quotes) in the first line, and nn numbers b_ib\_i in the second line, where b_ib\_i is the index of a jacket Vanya should wear in the ii-th day. Otherwise output the only line containing the word "No" (without the quotes). Jackets are indexed starting from one in the order they appear in the input.

If there are several satisfying schedules, you are allowed to output any of them.

힌트

In the first sample the answer "2 1 2 4" is not the only possible, another correct answer is "1 2 1 4".

In the second sample there is no schedule satisfying the requirements of Vanya, since he is obligated to wear the first jackets for both the first and the second days.

예제2

  1. 예제 1

    입력
    4 4
    25 25 30 50
    10 40
    20 30
    70 100
    50 50
    
    예상 출력
    Yes
    2 1 2 4
    
  2. 예제 2

    입력
    4 2
    30 40 50 60
    30 40
    50 60
    
    예상 출력
    No