Cafebazaar’s Applications

시간 제한1초메모리 제한2048 MB

요약
각 원소가 자기 자신을 포함하고 길이가 k 이상인 연속 부분 배열 안에서 가질 수 있는 최소 순위를 구한다.
난이도

보통10점 중 7점

유형
세그먼트 트리, 이분 탐색, 배열
정답자
아직 제출이 없습니다

문제

It’s the end of the year, and Cafebazaar has released a list, containing the number of users of each of its nn applications. Now, each application is eager to showcase its success through an advertisement image, which highlights a continuous subset of the application list containing the application itself. Also, for the image to be credible, it should contain at least kk applications, including itself.

For each application in this list, we need to determine the minimum possible rank this application can achieve within any valid subset, according to the number of users. The rank of an application within a subset is defined by the number of applications in that subset that have more users than it, plus one.

입력

The first line of input consists of two integers nn and kk (1≤k≤n≤1051 \le k \le n \le 10^5), where nn represents the total number of applications and kk represents the minimum number of applications in an advertisement image. The following nn lines contain information about each application: the iith line contain c_ic\_i, representing the number of users for the iith application (1≤c_i≤1081 \le c\_i \le 10^8).

출력

In the only line of output print nn space-separated integers. The iith integer should be the minimum rank that iith application can achieve within an advertisement image.

예제2

  1. 예제 1

    입력
    7 3
    15000000
    10000000
    30000000
    20000000
    200000
    70000000
    100000000
    
    예상 출력
    2 3 1 2 3 1 1
    
  2. 예제 2

    입력
    3 2
    10
    10
    10
    
    예상 출력
    1 1 1