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

21977번 - Financial Report 서브태스크다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB53191942.222%

문제

JOI mart is a shop which has N days of history. After opening JOI mart, the sales amount on the i-th day (1 ≤ i ≤ N) was Ai yen.

Bitaro is a shop manager of JOI mart, who will make a presentation of the financial report. For the presentation, he will choose some of the days, and show a bar chart of the sales amounts for the chosen days in chronological order. He will explain how the sales amounts changed for these days. In order to make the presentation much more impressive, he plans to choose the data for the presentation so that the presentation would give a better impression.

If Bitaro chooses the data of sales amounts for m days (1 ≤ m ≤ N) and he chooses the data of the p1, p2, . . . , pm-th days (1 ≤ p1 < p2 < · · · < pm ≤ N) after opening, the impression score of a bar chart is calculated as follows.

The impression score is equal to the number of times of making record-high sales amounts among the chosen days. In other words, the impression score is equal to the number of the indices j (1 ≤ j ≤ m) satisfying j = 1 or max{Ap1, Ap2, . . . , Apj−1} < Apj.

Bitaro wants to maximize the impression score, but the presentation might be unnatural for some choice of data. Thus, he decided to choose data satisfying both of the following conditions.

  • Bitaro will show the latest sales amount. In other words, pm = N is satisfied.
  • For any two consecutive data for the presentation, the difference of the dates is at most D days. In other words, if m ≥ 2, the inequality pj+1 − pj ≤ D is satisfied for every j (1 ≤ j ≤ m − 1).

Write a program which, given the data of sales amounts of JOI mart after opening and an integer D, calculate the maximum of the impression score of a bar chart for the presentation.

입력

Read the following data from the standard input. Given values are all integers.

N D
A1 · · · AN

출력

Write one line to the standard output. The output should contain the maximum of the impression score of a bar chart for the presentation.

제한

  • 1 ≤ N ≤ 300 000.
  • 1 ≤ D ≤ N.
  • 0 ≤ Ai ≤ 1 000 000 000 (1 ≤ i ≤ N).

서브태스크

번호배점제한
114

N ≤ 20.

214

N ≤ 400.

320

N ≤ 7 000.

412

D = 1.

55

D = N.

635

No additional constraints.

예제 입력 1

7 1
100 600 600 200 300 500 500

예제 출력 1

3

In this sample input, there are 7 possibilities for a bar chart for the presentation satisfying the conditions in the task statement.

  • If Bitaro shows a bar chart of the data of the 1, 2, 3, 4, 5, 6, 7-th days from opening, the impression score is 2 points.
  • If Bitaro shows a bar chart of the data of the 2, 3, 4, 5, 6, 7-th days from opening, the impression score is 1 point.
  • If Bitaro shows a bar chart of the data of the 3, 4, 5, 6, 7-th days from opening, the impression score is 1 point.
  • If Bitaro shows a bar chart of the data of the 4, 5, 6, 7-th days from opening, the impression score is 3 points.
  • If Bitaro shows a bar chart of the data of the 5, 6, 7-th days from opening, the impression score is 2 points.
  • If Bitaro shows a bar chart of the data of the 6, 7-th days from opening, the impression score is 1 point.
  • If Bitaro shows a bar chart of the data of the 7-th day from opening, the impression score is 1 points.

Therefore, the maximum of the impression score is 3 points. Your program is considered correct if it outputs 3.

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

예제 입력 2

6 6
100 500 200 400 600 300

예제 출력 2

4

In this sample input, the maximum impression score is achieved if Bitaro shows a bar chart of the data of the 1, 3, 4, 5, 6-th days from opening. If these days are chosen, the sales amounts of the chosen days are 100, 200, 400, 600, 300 yen. Since the number of times of making record-high sales amounts among the chosen data is 4, the impression score is 4 points. Thus, output 4.

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

예제 입력 3

11 2
1 4 4 2 2 4 9 5 7 0 3

예제 출력 3

4

In this sample input, the maximum impression score is achieved if Bitaro shows a bar chart of the data of the 1, 3, 5, 6, 8, 9, 11-th days from opening, for example. If these days are chosen, the sales amounts of the chosen days are 1, 4, 2, 4, 5, 7, 3 yen. Since number of times of making record-high sales amounts among the chosen data is 4, the impression score is 4 points. Thus, output 4. Note that, in this sample input, there are several ways to choose the data satisfying the conditions in the task statements for which the impression score is 4 points.

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

힌트

출처

Contest > JOI Open Contest > JOI Open Contest 2021 2번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

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

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