Logo
(追記) (追記ここまで)

34103번 - Exhibition 3 서브태스크다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 2048 MB91125.000%

문제

The JOI Art Museum is planning to hold an exhibition of paintings soon. The museum owns $N$ paintings numbered from 1ドル$ to $N,ドル and the beauty of painting $i$ (1ドル ≤ i ≤ N$) is given as $A_i$. For the exhibition, these paintings will be arranged in a single row from left to right, but the order in which they are placed has not yet been determined.

There will be $M$ magazines covering the exhibition. These magazines are numbered from 1ドル$ to $M$ in descending order of their influence. Each magazine will publish photographs of a certain contiguous segment of paintings in the arranged row. Specifically, magazine $j$ (1ドル ≤ j ≤ M$) will publish photographs of the $L_j , L_j + 1, \dots , R_j$-th paintings from the left in the row. The appeal of the article by magazine $j$ (1ドル ≤ j ≤ M$) is defined as the maximum beauty among the paintings it covers.

JOI-kun, the director of the JOI Art Museum, aims to arrange the paintings in a way that allows these magazines to write articles with greater appeal, thereby attracting more people to the exhibition. Since magazines with greater influence reach a larger audience, he wants to prioritize increasing the appeal of articles in more influential magazines. More precisely, let $b_j$ be the appeal of the article published by magazine $j$ (1ドル ≤ j ≤ M$), then JOI-kun wants to arrange the paintings so that the sequence $b = (b_1, b_2, \dots , b_M)$ is lexicographically maximized. Here, for two distinct sequences $b = (b_1, b_2, \dots , b_M)$ and $b' = (b'_1, b'_2, \dots , b'_M),ドル $b$ is said to be lexicographically larger than $b'$ when, for the smallest index $k$ (1ドル ≤ k ≤ M$) such that $b_k \ne b'_k,ドル $b_k > b'_k$ holds.

Write a program which, given the information of the paintings to be exhibited and the magazines covering the event, calculates the appeal of each magazine’s article when the paintings are arranged to maximize the lexicographical order of sequence $b = (b_1, b_2, \dots , b_M)$.

입력

Read the following data from the standard input.

$N$ $M$

$A_1$ $A_2$ $\cdots$ $A_N$

$L_1$ $R_1$

$L_2$ $R_2$

$\vdots$

$L_M$ $R_M$

출력

Write $M$ lines to the standard output. The $j$-th line (1ドル ≤ j ≤ M$) of the output should contain $b_j,ドル the appeal of the article published by magazine $j$. Here, the sequence $b = (b_1, b_2, \dots , b_M)$ must be lexicographically maximized.

제한

  • 1ドル ≤ N ≤ 100,円 000$.
  • 1ドル ≤ M ≤ 100,円 000$.
  • 1ドル ≤ A_i ≤ N$ (1ドル ≤ i ≤ N$).
  • 1ドル ≤ L_j ≤ R_j ≤ N$ (1ドル ≤ j ≤ M$).
  • Given values are all integers.

서브태스크

번호배점제한
119

$N ≤ 400,ドル $M ≤ 400$.

29

$N ≤ 400$.

319

$A_i ≤ 5$ (1ドル ≤ i ≤ N$).

412

$A_i = i$ (1ドル ≤ i ≤ N$).

517

For each $k$ (1ドル ≤ k ≤ N$), the number of $i$ (1ドル ≤ i ≤ N$) satisfying $A_i = k$ is at most 5ドル$.

624

No additional constraints.

예제 입력 1

4 4
1 2 1 2
1 1
2 3
4 4
3 4

예제 출력 1

2
2
1
2

When the paintings are arranged in the order 2,ドル 3, 4, 1$ from left to right, the appeal of each magazine’s article are determined as follows:

  • Magazine 1ドル$: Covers painting 2ドル$. Since the beauty of this painting is 2ドル,ドル the appeal of the article is 2ドル$.
  • Magazine 2ドル$: Covers paintings 3ドル$ and 4ドル$. Since the beauty of these paintings are 1ドル$ and 2ドル,ドル respectively, the appeal of the article is 2ドル$.
  • Magazine 3ドル$: Covers painting 1ドル$. Since the beauty of this painting is 1ドル,ドル the appeal of the article is 1ドル$.
  • Magazine 4ドル$: Covers paintings 4ドル$ and 1ドル$. Since the beauty of these paintings are 2ドル$ and 1ドル,ドル respectively, the appeal of the article is 2ドル$.

Thus, the sequence $b$ is $(2, 2, 1, 2)$. Since there is no arrangement of paintings that results in a lexicographically larger sequence than this, the output should be 2ドル,ドル 2ドル,ドル 1ドル,ドル and 2ドル$ in this order, separated by new lines.

This sample input satisfies the constraints of Subtasks 1, 2, 3, 5, and 6.

예제 입력 2

4 8
1 2 3 4
1 2
2 3
4 4
1 1
2 4
3 3
3 3
4 4

예제 출력 2

4
4
3
2
4
1
1
3

This sample input satisfies the constraints of all the subtasks.

예제 입력 3

12 10
6 2 2 5 2 5 2 3 3 3 2 2
3 5
10 12
12 12
2 4
8 9
10 11
1 3
7 9
9 10
10 11

예제 출력 3

6
5
5
6
5
3
6
5
5
3

This sample input satisfies the constraints of Subtasks 1, 2, and 6.

힌트

출처

Camp > JOI Spring Training Camp > JOI 2024/2025 Spring Training Camp 1-1번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
  • 이 문제의 채점 우선 순위는 2이다.
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /