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

26292번 - Lisa's Sequences 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
5 초 (추가 시간 없음) 1024 MB0000.000%

문제

Lisa loves playing with the sequences of integers. When she gets a new integer sequence $a_i$ of length $n,ドル she starts looking for all monotone subsequences. A monotone subsequence $[l, r]$ is defined by two indices $l$ and $r$ (1ドル \le l < r \le n$) such that $\forall i = l, l+1, \ldots, r-1: a_i \le a_{i+1}$ or $\forall i = l, l+1, \ldots, r-1: a_i \ge a_{i+1}$.

Lisa considers a sequence $a_i$ to be boring if there is a monotone subsequence $[l, r]$ that is as long as her boredom threshold $k,ドル that is when $r - l + 1 = k$.

Lucas has a sequence $b_i$ that he wants to present to Lisa, but the sequence might be boring for Lisa. So, he wants to change some elements of his sequence $b_i,ドル so that Lisa does not get bored playing with it. However, Lucas is lazy and wants to change as few elements of the sequence $b_i$ as possible. Your task is to help Lucas find the required changes.

입력

The first line of the input contains two integers $n$ and $k$ (3ドル \le k \le n \le 10^6$) --- the length of the sequence and Lisa's boredom threshold. The second line contains $n$ integers $b_i$ (1ドル \le b_i \le 99,999円$) --- the original sequence that Lucas has.

출력

On the first line output an integer $m$ --- the minimal number of elements in $b_i$ that needs to be changed to make the sequence not boring for Lisa. On the second line output $n$ integers $a_i$ (0ドル \le a_i \le 100,000円$), so that the sequence of integers $a_i$ is not boring for Lisa and is different from the original sequence $b_i$ in exactly $m$ positions.

제한

예제 입력 1

5 3
1 2 3 4 5

예제 출력 1

2
1 0 3 0 5

예제 입력 2

6 3
1 1 1 1 1 1

예제 출력 2

3
1 100000 0 1 0 1

예제 입력 3

6 4
1 1 4 4 1 1

예제 출력 3

1
1 1 4 0 1 1

예제 입력 4

6 4
4 4 4 2 2 2

예제 출력 4

2
4 4 0 2 0 2

예제 입력 5

6 4
4 4 4 3 4 4

예제 출력 5

1
4 4 100000 3 4 4

예제 입력 6

8 4
2 1 1 3 3 1 1 2

예제 출력 6

2
2 1 1 3 0 1 0 2

예제 입력 7

10 4
1 1 1 2 2 1 1 2 2 1

예제 출력 7

2
1 1 100000 2 2 100000 1 2 2 1

예제 입력 8

7 5
5 4 4 3 4 4 4

예제 출력 8

0
5 4 4 3 4 4 4

예제 입력 9

10 10
1 1 1 1 1 1 1 1 1 1

예제 출력 9

1
1 1 1 1 1 1 1 1 0 1

힌트

출처

ICPC > Regionals > Northern Eurasia > Northern Eurasia Finals > Northern Eurasia Finals 2022 L번

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

출처

대학교 대회

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

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