cswork / OA打开练习工作台

MicrosoftOA #57

Rank Open Businesses

估计简单可在线判题

考点(AI 标注)原地数组

Consider only open merchants and rank them by rating in descending order, then by distance in ascending order, then by original input index in ascending order. Return the first K indices; if fewer merchants are open, return all of them.

This site uses a standard input/output protocol.

输入格式

The first line contains N K, followed by N lines score distance isOpen. This site uses 1≤N≤100000, 0≤K≤100000, ratings 0..10⁹, distances 0..10⁹, and an open flag of 0 or 1.

输出格式

Output at most K 0-based indices in ranking order; if there are no results, output an empty line.

样例 1

输入:

4 2
90 4 1
95 8 0
90 2 1
85 1 1

输出:

2 0

样例 2

输入:

3 5
80 3 1
80 2 1
90 10 1

输出:

2 1 0

样例 3

输入:

1 1
10 1 0

输出:

样例说明

Example 1: index 1 is closed, and 2 and 0 have the same rating but 2 is closer, so output 2 0. Example 2: only 3 merchants are open, so return all of them: 2 1 0. Example 3: no merchant is open, so output an empty line.