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

21910번 - Fence Job 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 256 MB68393360.000%

문제

Fred the Farmer wants to redesign the fence of his house. Fred’s fence is composed of $n$ vertical wooden planks of various heights. The $i$-th plank’s height is $h_i$ (1ドル \le h_i \le n$). Initially, all heights are distinct.

In order to redesign the fence, Fred will choose some contiguous segment $[l\dots r]$ of planks and “level” them, by cutting them in order to make all heights equal to the minimum height on that segment. More specifically, the new heights of the segment become $h'_i = \min{\{h_l, h_{l+1}, \dots, h_r\}}$ for all $l \le i \le r$.

How many different designs can Fred obtain by applying this procedure several (possibly 0ドル$) times? Since the answer may be huge, you are required to output it modulo 10ドル^9 + 7$.

Two designs $A$ and $B$ are different if there is some plank that has a different height in $A$ than in $B$.

입력

The first line of the input contains $n$ (1ドル \le n \le 3,000円$), the number of planks of Fred’s fence.

The second line contains $n$ distinct integers $h_i$ (1ドル \le h_i \le n,ドル 1ドル \le i \le n$), the heights of each of the planks.

출력

Output a single integer, the number of different possible fence designs that can be obtained, modulo 10ドル^9 + 7$.

제한

예제 입력 1

3
1 3 2

예제 출력 1

4

예제 입력 2

5
1 2 3 4 5

예제 출력 2

42

예제 입력 3

7
1 4 2 5 3 6 7

예제 출력 3

124

힌트

출처

ICPC > Regionals > Europe > Southeastern European Regional Contest > SEERC 2020 F번

Contest > Open Cup > 2020/2021 Season > Stage 17: Grand Prix of Southern Europe F번

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

출처

대학교 대회

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

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