Cafebazaar's Applications
Time limit1sMemory limit2048 MB
For each application, find the minimum rank it can reach in a contiguous subsequence that contains it and at least k applications.
- Level
Medium7 of 10
- Topics
- Segment tree, Sorting, Array
- Solved
- No attempts yet
Problem
At the end of the year, Cafebazaar published a list of the number of users for each of its applications. Each application wants to show its success in an advertisement image. The image highlights a continuous subsequence of the list that contains the application itself. To be credible, the image must contain at least applications, including itself.
For each application, find the minimum rank it can achieve within any valid subsequence. The rank of an application within a subsequence is the number of applications in that subsequence with more users than it, plus one.
Input
The first line contains two integers and (), where is the total number of applications and is the minimum number of applications in an advertisement image. Each of the next lines contains , the number of users of the th application ().
Output
Print space-separated integers on one line. The th integer is the minimum rank that the th application can achieve in an advertisement image.